Changeset: d8d5a9e58055 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d8d5a9e58055
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        sql/backends/monet5/sql.c
Branch: simplify_scenario
Log Message:

merged with default


diffs (156 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -49291,7 +49291,7 @@ Write db snapshot to the given tar(.gz) 
 sql
 hot_snapshot
 unsafe pattern sql.hot_snapshot(X_0:str, X_1:bit):void 
-SQLhot_snapshot_wrap;
+SQLhot_snapshot;
 Write db snapshot to the given tar(.gz/.lz4/.bz/.xz) file on either server or 
client
 sql
 importColumn
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -37696,7 +37696,7 @@ Write db snapshot to the given tar(.gz) 
 sql
 hot_snapshot
 unsafe pattern sql.hot_snapshot(X_0:str, X_1:bit):void 
-SQLhot_snapshot_wrap;
+SQLhot_snapshot;
 Write db snapshot to the given tar(.gz/.lz4/.bz/.xz) file on either server or 
client
 sql
 importColumn
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -850,9 +850,11 @@ BATgroup_internal(BAT **groups, BAT **ex
        MT_rwlock_rdunlock(&b->thashlock);
        if (maxgrps == BUN_NONE) {
                MT_lock_set(&b->theaplock);
-               if (bi.unique_est != 0)
+               if (bi.unique_est != 0) {
                        maxgrps = (BUN) bi.unique_est;
-               else
+                       if (maxgrps > ci.ncand)
+                               maxgrps = ci.ncand;
+               } else
                        maxgrps = ci.ncand / 10;
                MT_lock_unset(&b->theaplock);
        }
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -141,8 +141,9 @@ MATpackIncrement(Client cntxt, MalBlkPtr
                        throw(MAL, "mat.pack", SQLSTATE(HY013) MAL_MALLOC_FAIL);
                }
                /* allocate enough space for the vheap, but not for strings,
-                * since BATappend does clever things for strings */
-               if ( b->tvheap && bn->tvheap && ATOMstorage(b->ttype) != 
TYPE_str){
+                * since BATappend does clever things for strings, and not for
+                * vheap views since they may well get shared */
+               if (b->tvheap && b->tvheap->parentid == b->batCacheid && 
bn->tvheap && ATOMstorage(b->ttype) != TYPE_str){
                        newsize =  b->tvheap->size * pieces;
                        if (HEAPextend(bn->tvheap, newsize, true) != 
GDK_SUCCEED) {
                                BBPunfix(b->batCacheid);
diff --git a/sql/ChangeLog.Sep2022 b/sql/ChangeLog.Sep2022
--- a/sql/ChangeLog.Sep2022
+++ b/sql/ChangeLog.Sep2022
@@ -1,6 +1,10 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Wed Apr  5 2023 Sjoerd Mullender <sjo...@acm.org>
+- When creating a hot snapshot, allow other clients to proceed, even
+  with updating queries.
+
 * Fri Mar 24 2023 Sjoerd Mullender <sjo...@acm.org>
 - Increased the size of a variable counting the number of changes made
   to the database (e.g. in case more than a 2 billion rows are added to
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -4225,25 +4225,9 @@ SQLsuspend_log_flushing(Client cntxt, Ma
 }
 
 str
-/*SQLhot_snapshot(void *ret, const str *tarfile_arg)*/
+/*SQLhot_snapshot(void *ret, const str *tarfile_arg [, bool onserver ])*/
 SQLhot_snapshot(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       char *tarfile = *getArgReference_str(stk, pci, 1);
-       mvc *mvc;
-
-       char *msg = getSQLContext(cntxt, mb, &mvc, NULL);
-       if (msg)
-               return msg;
-       lng result = store_hot_snapshot(mvc->session->tr->store, tarfile);
-       if (result)
-               return MAL_SUCCEED;
-       else
-               throw(SQL, "sql.hot_snapshot", GDK_EXCEPTION);
-}
-
-str
-SQLhot_snapshot_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{
        char *filename;
        bool onserver;
        char *msg = MAL_SUCCEED;
@@ -4255,7 +4239,7 @@ SQLhot_snapshot_wrap(Client cntxt, MalBl
        lng result;
 
        filename = *getArgReference_str(stk, pci, 1);
-       onserver = *getArgReference_bit(stk, pci, 2);
+       onserver = pci->argc == 3 ? *getArgReference_bit(stk, pci, 2) : true;
 
        msg = getSQLContext(cntxt, mb, &mvc, NULL);
        if (msg)
@@ -5065,7 +5049,7 @@ static mel_func sql_init_funcs[] = {
  pattern("sql", "hot_snapshot", SQLhot_snapshot, true, "Write db snapshot to 
the given tar(.gz) file", args(1,2, arg("",void),arg("tarfile",str))),
  pattern("sql", "resume_log_flushing", SQLresume_log_flushing, true, "Resume 
WAL log flushing", args(1,1, arg("",void))),
  pattern("sql", "suspend_log_flushing", SQLsuspend_log_flushing, true, 
"Suspend WAL log flushing", args(1,1, arg("",void))),
- pattern("sql", "hot_snapshot", SQLhot_snapshot_wrap, true, "Write db snapshot 
to the given tar(.gz/.lz4/.bz/.xz) file on either server or client", args(1,3, 
arg("",void),arg("tarfile", str),arg("onserver",bit))),
+ pattern("sql", "hot_snapshot", SQLhot_snapshot, true, "Write db snapshot to 
the given tar(.gz/.lz4/.bz/.xz) file on either server or client", args(1,3, 
arg("",void),arg("tarfile", str),arg("onserver",bit))),
  pattern("sql", "assert", SQLassert, false, "Generate an exception when 
b==true", args(1,3, arg("",void),arg("b",bit),arg("msg",str))),
  pattern("sql", "assert", SQLassertInt, false, "Generate an exception when 
b!=0", args(1,3, arg("",void),arg("b",int),arg("msg",str))),
  pattern("sql", "assert", SQLassertLng, false, "Generate an exception when 
b!=0", args(1,3, arg("",void),arg("b",lng),arg("msg",str))),
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -2401,8 +2401,13 @@ store_manager(sqlstore *store)
                const int sleeptime = 100;
                MT_lock_unset(&store->flush);
                MT_sleep_ms(sleeptime);
-               MT_lock_set(&store->commit);
-               MT_lock_set(&store->flush);
+               for (;;) {
+                       MT_lock_set(&store->commit);
+                       if (MT_lock_try(&store->flush))
+                               break;
+                       MT_lock_unset(&store->commit);
+                       MT_sleep_ms(sleeptime);
+               }
 
                if (GDKexiting()) {
                        MT_lock_unset(&store->commit);
@@ -2767,6 +2772,8 @@ store_hot_snapshot_to_stream(sqlstore *s
                goto end; // should already have set a GDK error
        close_stream(plan_stream);
        plan_stream = NULL;
+       MT_lock_unset(&store->lock);
+       locked = 2;
        r = hot_snapshot_write_tar(tar_stream, GDKgetenv("gdk_dbname"), 
buffer_get_buf(plan_buf));
        if (r != GDK_SUCCEED)
                goto end;
@@ -2783,7 +2790,8 @@ store_hot_snapshot_to_stream(sqlstore *s
 end:
        if (locked) {
                BBPtmunlock();
-               MT_lock_unset(&store->lock);
+               if (locked == 1)
+                       MT_lock_unset(&store->lock);
                MT_lock_unset(&store->flush);
        }
        if (plan_stream)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to