Changeset: 76e2b60d98e5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/76e2b60d98e5
Modified Files:
        sql/include/sql_catalog.h
        sql/storage/sql_catalog.c
        sql/storage/store.c
Branch: Jul2021
Log Message:

add lock around appending changes (concurrent workers could append concurrently)


diffs (37 lines):

diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -316,6 +316,7 @@ typedef struct sql_trans {
        ulng tid;                       /* transaction id */
 
        sql_store store;        /* keep link into the global store */
+       MT_Lock lock;           /* lock protecting concurrent writes to the 
changes list */
        list *changes;          /* list of changes */
        int logchanges;         /* count number of changes to be applied too 
the wal */
 
diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c
--- a/sql/storage/sql_catalog.c
+++ b/sql/storage/sql_catalog.c
@@ -79,9 +79,11 @@ trans_add(sql_trans *tr, sql_base *b, vo
        change->cleanup = cleanup;
        change->commit = commit;
        change->log = log;
+       MT_lock_set(&tr->lock);
        tr->changes = sa_list_append(tr->sa, tr->changes, change);
        if (log)
                tr->logchanges++;
+       MT_lock_unset(&tr->lock);
 }
 
 int
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3330,6 +3330,7 @@ sql_trans_create_(sqlstore *store, sql_t
        tr->sa = NULL;
        tr->store = store;
        tr->tid = store_transaction_id(store);
+       MT_lock_init(&tr->lock, "trans_lock");
 
        if (name) {
                if (!parent)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to