Changeset: 7936325c9612 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7936325c9612
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: unlock
Log Message:
use fixed set of locks for table level locking
diffs (103 lines):
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -15,6 +15,9 @@
static MT_Lock segs_lock = MT_LOCK_INITIALIZER("segs_lock");
static MT_Lock destroy_lock = MT_LOCK_INITIALIZER("destroy_lock");
+#define NR_TABLE_LOCKS 64
+static MT_Lock table_locks[NR_TABLE_LOCKS]; /* set of locks to protect table
changes (claim) */
+
storage *tobe_destroyed_dbat = NULL;
sql_delta *tobe_destroyed_delta = NULL;
@@ -913,6 +916,17 @@ table_claim_space(sql_trans *tr, sql_tab
return LOG_OK;
}
+void
+lock_table(sqlid id)
+{
+ MT_lock_set(&table_locks[id&(NR_TABLE_LOCKS-1)]);
+}
+
+void
+unlock_table(sqlid id)
+{
+ MT_lock_unset(&table_locks[id&(NR_TABLE_LOCKS-1)]);
+}
/*
* Claim cnt slots to store the tuples. The claim_tab should claim storage on
the level
* of the global transaction and mark the newly added storage slots unused on
the global
@@ -929,7 +943,7 @@ claim_tab(sql_trans *tr, sql_table *t, s
return 0;
/* use (resizeable) array of locks like BBP */
- store_lock();
+ lock_table(t->base.id);
s = t->data;
if (isNew(t) || isTempTable(t) || s->cs.cleared) {
@@ -968,11 +982,11 @@ claim_tab(sql_trans *tr, sql_table *t, s
BAT *ui, *uv;
if (0 && table_claim_space(tr, t, cnt) == LOG_ERR) {
- store_unlock();
+ unlock_table(t->base.id);
return LOG_ERR;
}
if (cs_real_update_bats(&s->cs, &ui, &uv) == LOG_ERR) {
- store_unlock();
+ unlock_table(t->base.id);
return LOG_ERR;
}
@@ -982,7 +996,7 @@ claim_tab(sql_trans *tr, sql_table *t, s
BUNappend(uv, &deleted, true) != GDK_SUCCEED) {
bat_destroy(ui);
bat_destroy(uv);
- store_unlock();
+ unlock_table(t->base.id);
return LOG_ERR;
}
}
@@ -997,7 +1011,7 @@ claim_tab(sql_trans *tr, sql_table *t, s
for(lng i=0; i<(lng)cnt; i++){
if (BUNappend(b, &deleted, true) != GDK_SUCCEED) {
bat_destroy(b);
- store_unlock();
+ unlock_table(t->base.id);
return LOG_ERR;
}
}
@@ -1006,7 +1020,7 @@ claim_tab(sql_trans *tr, sql_table *t, s
/* inserts only write */
s->cs.wtime = t->base.atime = t->s->base.atime = tr->atime = tr->wstime;
- store_unlock();
+ unlock_table(t->base.id);
return (size_t)slot;
}
@@ -2294,4 +2308,7 @@ bat_storage_init( store_functions *sf)
sf->gtrans_minmax = (gtrans_update_fptr)&minmax;
sf->cleanup = (cleanup_fptr)&cleanup;
+
+ for(int i=0;i<NR_TABLE_LOCKS;i++)
+ MT_lock_init(&table_locks[i], "table_lock");
}
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -21,8 +21,8 @@
#define CATALOG_VERSION 52300
int catalog_version = 0;
-static MT_Lock bs_lock = MT_LOCK_INITIALIZER("bs_lock");
-static MT_Lock flush_lock = MT_LOCK_INITIALIZER("flush_lock");
+static MT_Lock bs_lock = MT_LOCK_INITIALIZER("bs_lock"); /*
protect access of the gtrans structure */
+static MT_Lock flush_lock = MT_LOCK_INITIALIZER("flush_lock"); /*
protect flushing and hot snapshots */
static sqlid store_oid = 0;
static sqlid prev_oid = 0;
static size_t new_trans_size = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list