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

If a bat doesn't have to be backed up, don't keep BBPSYNCING bit.
The bit indicates that the bat is between being backed up (i.e. moved
to backup directory) and saved, so the heap file may not exist in the
normal location.  If it isn't being backed up, the heaps should be in
the normal location, so we don't have to wait for the save (that won't
come anyway).


diffs (89 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3213,7 +3213,8 @@ BBPsync(int cnt, bat *restrict subcommit
                                MT_lock_set(&GDKswapLock(i));
                        /* set flag that we're syncing, i.e. that we'll
                         * be between moving heap to backup dir and
-                        * saving the new version */
+                        * saving the new version, in other words, the
+                        * heap may not exist in the usual location */
                        BBP_status_on(i, BBPSYNCING);
                        /* wait until unloading is finished before
                         * attempting to make a backup */
@@ -3231,38 +3232,46 @@ BBPsync(int cnt, bat *restrict subcommit
                                break;
                        }
                        if (BBP_status(i) & BBPEXISTING) {
-                               if (b != NULL && BBPbackup(b, subcommit != 
NULL) != GDK_SUCCEED) {
-                                       BBP_status_off(i, BBPSYNCING);
-                                       if (lock)
-                                               MT_lock_unset(&GDKswapLock(i));
-                                       break;
-                               }
-                       } else if (subcommit && (b = BBP_desc(i)) && 
BBP_status(i) & BBPDELETED) {
-                               char o[10];
-                               char *f;
-                               snprintf(o, sizeof(o), "%o", (unsigned) 
b->batCacheid);
-                               f = GDKfilepath(b->theap->farmid, BAKDIR, o, 
gettailname(b));
-                               if (f == NULL) {
+                               if (b != NULL) {
+                                       if (BBPbackup(b, subcommit != NULL) != 
GDK_SUCCEED) {
+                                               BBP_status_off(i, BBPSYNCING);
+                                               if (lock)
+                                                       
MT_lock_unset(&GDKswapLock(i));
+                                               break;
+                                       }
+                               } else {
+                                       /* file has not been moved to
+                                        * backup dir, so no need for
+                                        * other threads to wait */
                                        BBP_status_off(i, BBPSYNCING);
-                                       if (lock)
-                                               MT_lock_unset(&GDKswapLock(i));
-                                       ret = GDK_FAIL;
-                                       goto bailout;
                                }
-                               if (MT_access(f, F_OK) == 0)
-                                       file_move(b->theap->farmid, BAKDIR, 
SUBDIR, o, gettailname(b));
-                               GDKfree(f);
-                               f = GDKfilepath(b->theap->farmid, BAKDIR, o, 
"theap");
-                               if (f == NULL) {
-                                       BBP_status_off(i, BBPSYNCING);
-                                       if (lock)
-                                               MT_lock_unset(&GDKswapLock(i));
-                                       ret = GDK_FAIL;
-                                       goto bailout;
+                       } else {
+                               BBP_status_off(i, BBPSYNCING);
+                               if (subcommit && (b = BBP_desc(i)) && 
BBP_status(i) & BBPDELETED) {
+                                       char o[10];
+                                       char *f;
+                                       snprintf(o, sizeof(o), "%o", (unsigned) 
b->batCacheid);
+                                       f = GDKfilepath(b->theap->farmid, 
BAKDIR, o, gettailname(b));
+                                       if (f == NULL) {
+                                               if (lock)
+                                                       
MT_lock_unset(&GDKswapLock(i));
+                                               ret = GDK_FAIL;
+                                               goto bailout;
+                                       }
+                                       if (MT_access(f, F_OK) == 0)
+                                               file_move(b->theap->farmid, 
BAKDIR, SUBDIR, o, gettailname(b));
+                                       GDKfree(f);
+                                       f = GDKfilepath(b->theap->farmid, 
BAKDIR, o, "theap");
+                                       if (f == NULL) {
+                                               if (lock)
+                                                       
MT_lock_unset(&GDKswapLock(i));
+                                               ret = GDK_FAIL;
+                                               goto bailout;
+                                       }
+                                       if (MT_access(f, F_OK) == 0)
+                                               file_move(b->theap->farmid, 
BAKDIR, SUBDIR, o, "theap");
+                                       GDKfree(f);
                                }
-                               if (MT_access(f, F_OK) == 0)
-                                       file_move(b->theap->farmid, BAKDIR, 
SUBDIR, o, "theap");
-                               GDKfree(f);
                        }
                        if (lock)
                                MT_lock_unset(&GDKswapLock(i));
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to