Changeset: aa65385ebcb8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aa65385ebcb8
Modified Files:
        gdk/gdk_bbp.c
        gdk/gdk_logger.c
Branch: Sep2022
Log Message:

Merge with Jan2022 branch.


diffs (131 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3862,61 +3862,54 @@ BBPsync(int cnt, bat *restrict subcommit
                                   &obbpf, &nbbpf);
        }
 
-       if (ret == GDK_SUCCEED) {
-               int idx = 0;
-               bool lock = locked_by == 0 || locked_by != MT_getpid();
-
-               while (++idx < cnt) {
-                       bat i = subcommit ? subcommit[idx] : idx;
-                       /* BBP_desc(i) may be NULL */
-                       BUN size = sizes ? sizes[idx] : BUN_NONE;
-                       BATiter bi;
-
-                       if (BBP_status(i) & BBPPERSISTENT) {
-                               BAT *b = dirty_bat(&i, subcommit != NULL);
-                               if (i <= 0) {
-                                       break;
-                               }
-                               bi = bat_iterator(BBP_desc(i));
-                               assert(sizes == NULL || size <= bi.count);
-                               assert(sizes == NULL || bi.width == 0 || 
(bi.type == TYPE_msk ? ((size + 31) / 32) * 4 : size << bi.shift) <= bi.hfree);
-                               if (size > bi.count) /* includes sizes==NULL */
-                                       size = bi.count;
-                               bi.b->batInserted = size;
-                               if (b && size != 0) {
-                                       /* wait for BBPSAVING so that we
-                                        * can set it, wait for
-                                        * BBPUNLOADING before
-                                        * attempting to save */
-                                       for (;;) {
-                                               if (lock)
-                                                       
MT_lock_set(&GDKswapLock(i));
-                                               if (!(BBP_status(i) & 
(BBPSAVING|BBPUNLOADING)))
-                                                       break;
-                                               if (lock)
-                                                       
MT_lock_unset(&GDKswapLock(i));
-                                               BBPspin(i, __func__, 
BBPSAVING|BBPUNLOADING);
-                                       }
-                                       BBP_status_on(i, BBPSAVING);
+       for (int idx = 1; ret == GDK_SUCCEED && idx < cnt; idx++) {
+               bat i = subcommit ? subcommit[idx] : idx;
+               /* BBP_desc(i) may be NULL */
+               BUN size = sizes ? sizes[idx] : BUN_NONE;
+               BATiter bi;
+
+               if (BBP_status(i) & BBPPERSISTENT) {
+                       BAT *b = dirty_bat(&i, subcommit != NULL);
+                       if (i <= 0) {
+                               ret = GDK_FAIL;
+                               break;
+                       }
+                       bi = bat_iterator(BBP_desc(i));
+                       assert(sizes == NULL || size <= bi.count);
+                       assert(sizes == NULL || bi.width == 0 || (bi.type == 
TYPE_msk ? ((size + 31) / 32) * 4 : size << bi.shift) <= bi.hfree);
+                       if (size > bi.count) /* includes sizes==NULL */
+                               size = bi.count;
+                       bi.b->batInserted = size;
+                       if (b && size != 0) {
+                               /* wait for BBPSAVING so that we
+                                * can set it, wait for
+                                * BBPUNLOADING before
+                                * attempting to save */
+                               for (;;) {
+                                       if (lock)
+                                               MT_lock_set(&GDKswapLock(i));
+                                       if (!(BBP_status(i) & 
(BBPSAVING|BBPUNLOADING)))
+                                               break;
                                        if (lock)
                                                MT_lock_unset(&GDKswapLock(i));
-                                       ret = BATsave_iter(b, &bi, size);
-                                       BBP_status_off(i, BBPSAVING);
+                                       BBPspin(i, __func__, 
BBPSAVING|BBPUNLOADING);
                                }
-                       } else {
-                               bi = bat_iterator(NULL);
-                       }
-                       if (ret == GDK_SUCCEED) {
-                               n = BBPdir_step(i, size, n, buf, sizeof(buf), 
&obbpf, nbbpf, &bi);
+                               BBP_status_on(i, BBPSAVING);
+                               if (lock)
+                                       MT_lock_unset(&GDKswapLock(i));
+                               ret = BATsave_iter(b, &bi, size);
+                               BBP_status_off(i, BBPSAVING);
                        }
-                       bat_iterator_end(&bi);
-                       if (n == -2)
-                               break;
-                       /* we once again have a saved heap */
+               } else {
+                       bi = bat_iterator(NULL);
                }
-               if (idx < cnt) {
-                       ret = GDK_FAIL;
+               if (ret == GDK_SUCCEED) {
+                       n = BBPdir_step(i, size, n, buf, sizeof(buf), &obbpf, 
nbbpf, &bi);
+                       if (n < -1)
+                               ret = GDK_FAIL;
                }
+               bat_iterator_end(&bi);
+               /* we once again have a saved heap */
        }
 
        TRC_DEBUG(PERF, "write time %d\n", (t0 = GDKms()) - t1);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -893,9 +893,9 @@ la_apply(logger *lg, logaction *c, int t
 static void
 la_destroy(logaction *c)
 {
-       if (c->b && (c->type == LOG_UPDATE || c->type == LOG_UPDATE_BULK))
+       if ((c->type == LOG_UPDATE || c->type == LOG_UPDATE_BULK) && c->b)
                logbat_destroy(c->b);
-       if (c->uid && c->type == LOG_UPDATE)
+       if (c->type == LOG_UPDATE && c->uid)
                logbat_destroy(c->uid);
 }
 
@@ -1669,6 +1669,8 @@ bm_subcommit(logger *lg)
        sizes[i] = BATcount(dcatalog);
        n[i++] = dcatalog->batCacheid;
 
+       if (cleanup < (lg->cnt/2))
+               cleanup = 0;
        if (cleanup && (rcnt=cleanup_and_swap(lg, r, bids, lids, cnts, 
catalog_bid, catalog_id, dcatalog, cleanup)) < 0) {
                GDKfree(n);
                GDKfree(r);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to