Changeset: 67de2c362a2d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/67de2c362a2d
Modified Files:
gdk/gdk_logger.c
Branch: Jul2021
Log Message:
Fixed a race condition.
bm_commit locks the logger and then persists all "new" bats (from
batInserted to batCount in catalog_bid). It then unlocks the logger and
call bm_subcommit. bm_subcommit then locks the logger again and saves
and syncs all to-be-committed bats and updated the batInserted value of
catalog_bid (and the other catalog bats) to the then current value of
batCount. Between the unlock in bm_commit and the subsequent lock in
bm_subcommit, the batCount of catalog_bid could be increased, meaning
that any bats that are added then are not made persistent.
We fix this by not unlocking and relocking.
diffs (35 lines):
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1575,11 +1575,12 @@ cleanup_and_swap(logger *lg, int *r, con
return rcnt;
}
+/* this function is called with logger_lock() held; it releases the lock
+ * before returning */
static gdk_return
bm_subcommit(logger *lg)
{
BUN p, q;
- logger_lock(lg);
BAT *catalog_bid = lg->catalog_bid;
BAT *catalog_id = lg->catalog_id;
BAT *dcatalog = lg->dcatalog;
@@ -1901,6 +1902,8 @@ logger_load(int debug, const char *fn, c
BBPretain(lg->catalog_id->batCacheid);
BBPretain(lg->dcatalog->batCacheid);
+ logger_lock(lg);
+ /* bm_subcommit releases the lock */
if (bm_subcommit(lg) != GDK_SUCCEED) {
/* cannot commit catalog, so remove log */
MT_remove(filename);
@@ -2840,7 +2843,7 @@ bm_commit(logger *lg)
fprintf(stderr, "#bm_commit: create %d (%d)\n",
bid, BBP_lrefs(bid));
}
- logger_unlock(lg);
+ /* bm_subcommit releases the lock */
return bm_subcommit(lg);
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]