Changeset: a7f68dc5ac25 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a7f68dc5ac25
Modified Files:
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_heap.c
        gdk/gdk_imprints.c
        gdk/gdk_private.h
        sql/backends/monet5/sql_gencode.c
Branch: Jun2023
Log Message:

Merge with Sep2022 branch.


diffs (163 lines):

diff --git a/gdk/ChangeLog.Sep2022 b/gdk/ChangeLog.Sep2022
--- a/gdk/ChangeLog.Sep2022
+++ b/gdk/ChangeLog.Sep2022
@@ -1,6 +1,13 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Thu Apr 20 2023 Sjoerd Mullender <[email protected]>
+- Fixed yet another occurrence of a missing .tailN file.  This one could
+  happen if a string bat was appended to in stages so that between appends
+  the column was committed.  If an append caused both a realloc of the
+  tail heap because it was getting longer and a realloc because it got
+  wider, the file might get removed before the GDK level commit happened.
+
 * Fri Mar 24 2023 Sjoerd Mullender <[email protected]>
 - When processing the WAL, if a to-be-destroyed object cannot be found,
   don't stop, but keep processing the rest of the WAL.
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3600,34 +3600,21 @@ BBPbackup(BAT *b, bool subcommit)
 }
 
 static inline void
-BBPcheckHeap(bool subcommit, Heap *h)
+BBPcheckHeap(Heap *h)
 {
        struct stat statb;
        char *path;
 
-       if (subcommit) {
-               char *s = strrchr(h->filename, DIR_SEP);
-               if (s)
-                       s++;
-               else
-                       s = h->filename;
-               path = GDKfilepath(0, BAKDIR, s, NULL);
-               if (path == NULL)
-                       return;
-               if (MT_stat(path, &statb) < 0) {
-                       GDKfree(path);
-                       path = GDKfilepath(0, BATDIR, h->filename, NULL);
-                       if (path == NULL)
-                               return;
-                       if (MT_stat(path, &statb) < 0) {
-                               GDKsyserror("cannot stat file %s (expected size 
%zu)\n",
-                                           path, h->free);
-                               assert(0);
-                               GDKfree(path);
-                               return;
-                       }
-               }
-       } else {
+       char *s = strrchr(h->filename, DIR_SEP);
+       if (s)
+               s++;
+       else
+               s = h->filename;
+       path = GDKfilepath(0, BAKDIR, s, NULL);
+       if (path == NULL)
+               return;
+       if (MT_stat(path, &statb) < 0) {
+               GDKfree(path);
                path = GDKfilepath(0, BATDIR, h->filename, NULL);
                if (path == NULL)
                        return;
@@ -3650,7 +3637,7 @@ BBPcheckHeap(bool subcommit, Heap *h)
 }
 
 static void
-BBPcheckBBPdir(bool subcommit)
+BBPcheckBBPdir(void)
 {
        FILE *fp;
        int lineno = 0;
@@ -3658,10 +3645,14 @@ BBPcheckBBPdir(bool subcommit)
        unsigned bbpversion;
        lng logno, transid;
 
-       fp = GDKfileopen(0, BATDIR, "BBP", "dir", "r");
+       fp = GDKfileopen(0, BAKDIR, "BBP", "dir", "r");
        assert(fp != NULL);
-       if (fp == NULL)
-               return;
+       if (fp == NULL) {
+               fp = GDKfileopen(0, BATDIR, "BBP", "dir", "r");
+               assert(fp != NULL);
+               if (fp == NULL)
+                       return;
+       }
        bbpversion = BBPheader(fp, &lineno, &bbpsize, &logno, &transid);
        if (bbpversion == 0) {
                fclose(fp);
@@ -3716,9 +3707,9 @@ BBPcheckBBPdir(bool subcommit)
                        continue;
                }
                if (b.theap->free > 0)
-                       BBPcheckHeap(subcommit, b.theap);
+                       BBPcheckHeap(b.theap);
                if (b.tvheap != NULL && b.tvheap->free > 0)
-                       BBPcheckHeap(subcommit, b.tvheap);
+                       BBPcheckHeap(b.tvheap);
        }
 }
 
@@ -3753,6 +3744,9 @@ BBPsync(int cnt, bat *restrict subcommit
 
        TRC_DEBUG_IF(PERF) t0 = t1 = GDKusec();
 
+       if ((GDKdebug & TAILCHKMASK) && !GDKinmemory(0))
+               BBPcheckBBPdir();
+
        ret = BBPprepare(subcommit != NULL);
 
        /* PHASE 1: safeguard everything in a backup-dir */
@@ -3873,9 +3867,6 @@ BBPsync(int cnt, bat *restrict subcommit
                 * succeeded, so no changing of ret after this
                 * call anymore */
 
-               if ((GDKdebug & TAILCHKMASK) && !GDKinmemory(0))
-                       BBPcheckBBPdir(subcommit != NULL);
-
                if (MT_rename(bakdir, deldir) < 0 &&
                    /* maybe there was an old deldir, so remove and try again */
                    (GDKremovedir(0, DELDIR) != GDK_SUCCEED ||
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -603,7 +603,8 @@ GDKupgradevarheap(BAT *b, var_t v, BUN c
                b->oldtail = old;
                ATOMIC_OR(&old->refs, DELAYEDREMOVE);
        } else {
-               HEAPdecref(old, true);
+               ValPtr p = BATgetprop_nolock(b, (enum prop_t) 20);
+               HEAPdecref(old, p == NULL || strcmp(((Heap*) 
p->val.pval)->filename, old->filename) != 0);
        }
        MT_lock_unset(&b->theaplock);
        return GDK_SUCCEED;
diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -1169,7 +1169,6 @@ backend_dumpproc(backend *be, Client c, 
        if (c->curprg->def->errors) {
                sql_error(m, 10, SQLSTATE(42000) "Internal error while 
compiling statement: %s", c->curprg->def->errors);
                res = -1;
-               goto cleanup;
        }
 
        // restore the context for the wrapper code
diff --git a/sql/test/BugTracker-2015/Tests/schema-trigger.Bug-3710.test 
b/sql/test/BugTracker-2015/Tests/schema-trigger.Bug-3710.test
--- a/sql/test/BugTracker-2015/Tests/schema-trigger.Bug-3710.test
+++ b/sql/test/BugTracker-2015/Tests/schema-trigger.Bug-3710.test
@@ -8,9 +8,7 @@ statement error
 CREATE TRIGGER marketdata.calc_sdate BEFORE INSERT ON marketdata.quotes
 FOR EACH ROW
 BEGIN ATOMIC
- update marketdata.quotes set i = quotes.i +2 where quotes.i < 2
-
-statement error
+ update marketdata.quotes set i = quotes.i +2 where quotes.i < 2;
 END
 
 statement ok
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to