Changeset: 46605400f0be for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/46605400f0be
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        monetdb5/modules/mal/querylog.c
Branch: default
Log Message:

Merge with Jul2021 branch.


diffs (186 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -2128,7 +2128,7 @@ BATroles(BAT *b, const char *tnme)
 /* rather than deleting X.new, we comply with the commit protocol and
  * move it to backup storage */
 static gdk_return
-backup_new(Heap *hp)
+backup_new(Heap *hp, bool lock)
 {
        int batret, bakret, ret = -1;
        char *batpath, *bakpath;
@@ -2139,7 +2139,8 @@ backup_new(Heap *hp)
        bakpath = GDKfilepath(hp->farmid, BAKDIR, hp->filename, ".new");
        if (batpath != NULL && bakpath != NULL) {
                /* file actions here interact with the global commits */
-               MT_lock_set(&GDKtmLock);
+               if (lock)
+                       MT_lock_set(&GDKtmLock);
 
                batret = MT_stat(batpath, &st);
                bakret = MT_stat(bakpath, &st);
@@ -2159,7 +2160,8 @@ backup_new(Heap *hp)
                } else {
                        ret = 0;
                }
-               MT_lock_unset(&GDKtmLock);
+               if (lock)
+                       MT_lock_unset(&GDKtmLock);
        }
        GDKfree(batpath);
        GDKfree(bakpath);
@@ -2178,11 +2180,12 @@ HEAPchangeaccess(Heap *hp, int dstmode, 
        if (dstmode == BAT_WRITE) {
                if (hp->storage != STORE_PRIV)
                        hp->dirty = true;       /* exception c does not make it 
dirty */
-               return STORE_PRIV;      /* 4=>6,5=>7,c=>6 persistent BAT_WRITE 
needs STORE_PRIV */
+//             return STORE_PRIV;      /* 4=>6,5=>7,c=>6 persistent BAT_WRITE 
needs STORE_PRIV */
+               return STORE_MMAP;
        }
        if (hp->storage == STORE_MMAP) {        /* 6=>4 */
                hp->dirty = true;
-               return backup_new(hp) != GDK_SUCCEED ? STORE_INVALID : 
STORE_MMAP;      /* only called for existing bats */
+               return backup_new(hp, true) != GDK_SUCCEED ? STORE_INVALID : 
STORE_MMAP;        /* only called for existing bats */
        }
        return hp->storage;     /* 7=>5 */
 }
@@ -2194,7 +2197,7 @@ HEAPcommitpersistence(Heap *hp, bool wri
        if (existing) {         /* existing, ie will become transient */
                if (hp->storage == STORE_MMAP && hp->newstorage == STORE_PRIV 
&& writable) {    /* 6=>2 */
                        hp->dirty = true;
-                       return backup_new(hp) != GDK_SUCCEED ? STORE_INVALID : 
STORE_MMAP;      /* only called for existing bats */
+                       return backup_new(hp, false) != GDK_SUCCEED ? 
STORE_INVALID : STORE_MMAP;       /* only called for existing bats */
                }
                return hp->newstorage;  /* 4=>0,5=>1,7=>3,c=>a no change */
        }
@@ -2206,11 +2209,12 @@ HEAPcommitpersistence(Heap *hp, bool wri
 
        if (hp->newstorage == STORE_MMAP)
                hp->dirty = true;       /* 2=>6 */
-       return STORE_PRIV;      /* 1=>5,2=>6,3=>7,a=>c,b=>6 states */
+//     return STORE_PRIV;      /* 1=>5,2=>6,3=>7,a=>c,b=>6 states */
+       return STORE_MMAP;
 }
 
 
-#define ATOMappendpriv(t, h) (ATOMstorage(t) != TYPE_str || GDK_ELIMDOUBLES(h))
+#define ATOMappendpriv(t, h) (ATOMstorage(t) != TYPE_str /*|| 
GDK_ELIMDOUBLES(h) */)
 
 /* change the heap modes at a commit */
 gdk_return
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1467,7 +1467,6 @@ BATappend_or_update(BAT *b, BAT *p, cons
                                        goto bailout;
                                }
                                if (BUNappend(b, new, force) != GDK_SUCCEED) {
-                                       MT_rwlock_wrunlock(&b->thashlock);
                                        bat_iterator_end(&ni);
                                        return GDK_FAIL;
                                }
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3625,7 +3625,9 @@ BBPsync(int cnt, bat *restrict subcommit
                                        BATiter bi = bat_iterator(b);
                                        if (size > bi.count)
                                                size = bi.count;
+                                       MT_rwlock_rdlock(&b->thashlock);
                                        ret = BATsave_locked(b, &bi, size);
+                                       MT_rwlock_rdunlock(&b->thashlock);
                                        bat_iterator_end(&bi);
                                        BBP_status_off(i, BBPSAVING);
                                }
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -560,7 +560,7 @@ GDKload(int farmid, const char *nme, con
                                        /* we couldn't read all, error
                                         * already generated */
                                        GDKfree(ret);
-                                       GDKerror("short read from heap %s%s\n", 
nme, ext ? ext : "");
+                                       GDKerror("short read from heap %s%s%s, 
expected %zu, missing %zd\n", nme, ext ? "." : "", ext ? ext : "", size, 
n_expected);
                                        ret = NULL;
                                }
 #ifndef NDEBUG
@@ -881,17 +881,8 @@ BATsave_locked(BAT *b, BATiter *bi, BUN 
                        b->batDirtydesc = false;
                }
                MT_lock_unset(&b->theaplock);
-               if (MT_rwlock_rdtry(&b->thashlock)) {
-                       /* if we can't get the lock, don't bother saving
-                        * the hash (normally, the hash lock should not
-                        * be acquired when the heap lock has already
-                        * been acquired, and here we have the heap
-                        * lock, so we must be careful with the hash
-                        * lock) */
-                       if (b->thash && b->thash != (Hash *) 1)
-                               BAThashsave(b, dosync);
-                       MT_rwlock_rdunlock(&b->thashlock);
-               }
+               if (b->thash && b->thash != (Hash *) 1)
+                       BAThashsave(b, dosync);
        }
        return err;
 }
@@ -901,11 +892,11 @@ BATsave(BAT *b)
 {
        gdk_return rc;
 
+       BATiter bi = bat_iterator(b);
        MT_rwlock_rdlock(&b->thashlock);
-       BATiter bi = bat_iterator(b);
        rc = BATsave_locked(b, &bi, bi.count);
+       MT_rwlock_rdunlock(&b->thashlock);
        bat_iterator_end(&bi);
-       MT_rwlock_rdunlock(&b->thashlock);
        return rc;
 }
 
diff --git a/monetdb5/modules/mal/querylog.c b/monetdb5/modules/mal/querylog.c
--- a/monetdb5/modules/mal/querylog.c
+++ b/monetdb5/modules/mal/querylog.c
@@ -167,12 +167,16 @@ QLOGcreate(str hnme, str tnme, int tt)
 
        snprintf(buf, 128, "querylog_%s_%s", hnme, tnme);
        b = BATdescriptor(BBPindex(buf));
-       if (b)
-               return b;
+       if (b) {
+               /* make append-only in case this wasn't done when created */
+               return BATsetaccess(b, BAT_APPEND);
+       }
 
        b = COLnew(0, tt, 1 << 16, PERSISTENT);
        if (b == NULL)
                return NULL;
+       if ((b = BATsetaccess(b, BAT_APPEND)) == NULL)
+               return NULL;
 
        if (BBPrename(b->batCacheid, buf) != 0 ||
                BATmode(b, false) != GDK_SUCCEED) {
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1374,6 +1374,9 @@ def PerformDir(env, testdir, testlist, a
                                             pollfile)
                         os.chdir(TSTTRGDIR)
                         pSrvr.LaunchIt()
+                        if pSrvr.port is None:
+                            print('\nFailed to start server.\n')
+                            break
                         os.environ['MAPIPORT'] = env['MAPIPORT'] = pSrvr.port
                         SetExecEnv(env['exe'],pSrvr.port,verbose)
                     if global_timeout and start_time + global_timeout < 
time.time():
@@ -2764,6 +2767,9 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
                 Srvr.extend(mserver5_opts)
                 pSrvr = ServerClass(Srvr, SrvrOut, SrvrErr, TIMEOUT, 
os.path.join(dbpath, '.started'))
                 pSrvr.LaunchIt()
+                if pSrvr.port is None:
+                    print('\nFailed to start server.\n')
+                    return 'serverfail'
                 os.environ['MAPIPORT'] = env['MAPIPORT'] = pSrvr.port
                 SetExecEnv(exe,pSrvr.port,verbose)
             else:
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to