Changeset: 1d653d6c10d2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1d653d6c10d2
Modified Files:
        sql/storage/bat/bat_storage.c
        sql/storage/store.c
Branch: Jan2022
Log Message:

A potential race condition in merge_segments code:
merge_segments depends on sqlstore::store being a
monotonically increasing sequence of transaction objects
in terms of start timestamps sql_trans::ts. Because
sql_trans::ts is set to the commit timestamp in
sql_trans_commit and is not immediately removed from
the sqlstore::store active list.

It is however highly unlikely in pre-group-commit
code that this actually occurs
as a WAL flush/sync is executed by one of the racers
and not by the other which makes the latter
win the race effectively always in a safe manner.

However on post-group-commit code, i.e. Sep2022 and up,
this race condition is much more likely and easily reproduced.


diffs (23 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
@@ -410,8 +410,6 @@ merge_segments(storage *s, sql_trans *tr
                                node *n = store->active->h;
                                for (int i = 0; i < store->active->cnt; i++, n 
= n->next) {
                                        ulng active = ((sql_trans*)n->data)->ts;
-                                       if(active == seg->ts || active == 
cur->ts)
-                                               continue; /* pretent that a 
recently committed transaction has already committed and is no longer active */
                                        if (active == tr->ts)
                                                continue; /* pretent that 
committing transaction has already committed and is no longer active */
                                        if (seg->ts < active && cur->ts < 
active)
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4018,7 +4018,6 @@ sql_trans_commit(sql_trans *tr)
                        }
                        n = next;
                }
-               tr->ts = commit_ts;
                store_unlock(store);
                MT_lock_unset(&store->commit);
                list_destroy(tr->changes);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to