Changeset: 97f68c376894 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/97f68c376894 Modified Files: gdk/gdk_bbp.c Branch: default Log Message:
Merge with Dec2023 branch. diffs (209 lines): diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -120,6 +120,7 @@ static MT_Lock BBPnameLock = MT_LOCK_INI static bat BBP_hash[BBP_mask+1]; /* BBP logical name hash buckets */ static MT_Lock GDKcacheLock = MT_LOCK_INITIALIZER(GDKcacheLock); static bat BBP_free; +static uint32_t BBP_nfree; #define BBP_FREE_LOWATER 10 #define BBP_FREE_HIWATER 50 @@ -2003,6 +2004,7 @@ BBPinit(bool allow_hge_upgrade) if (BBP_desc(i)->batCacheid == 0) { BBP_next(i) = BBP_free; BBP_free = i; + BBP_nfree++; } } @@ -2693,6 +2695,7 @@ maybeextend(void) BBP_next(sz) = ++size; } BBP_next(size) = 0; + BBP_nfree += BBP_FREE_LOWATER; return GDK_SUCCEED; } @@ -2731,6 +2734,7 @@ BBPallocbat(int tt) for (int x = 0; x < BBP_FREE_LOWATER && i; x++) { assert(BBP_next(i) == 0 || BBP_next(i) > i); t->nfreebats++; + BBP_nfree--; l = i; i = BBP_next(i); } @@ -2845,6 +2849,7 @@ BBPhandover(struct freebats *t, uint32_t if (n >= t->nfreebats) { bid = t->freebats; t->freebats = 0; + BBP_nfree += t->nfreebats; t->nfreebats = 0; } else { p = &t->freebats; @@ -2852,6 +2857,7 @@ BBPhandover(struct freebats *t, uint32_t p = &BBP_next(*p); bid = *p; *p = 0; + BBP_nfree += n; t->nfreebats -= n; } p = &BBP_free; @@ -2934,9 +2940,10 @@ BBPclear(bat i) } void -BBPrelinquish(struct freebats *t) +BBPrelinquish(void) { - if (t->nfreebats == 0) + struct freebats *t = MT_thread_getfreebats(); + if (t == NULL || t->nfreebats == 0) return; MT_lock_set(&GDKcacheLock); while (t->nfreebats > 0) { @@ -4672,6 +4679,7 @@ gdk_bbp_reset(void) int i; BBP_free = 0; + BBP_nfree = 0; while (BBPlimit > BBPINIT) { BBPlimit -= BBPINIT; assert(BBPlimit >= 0); @@ -4905,4 +4913,5 @@ BBPprintinfo(void) printf("%d persistent bats using %zu virtual memory (%zu malloced)\n", pn, pvm, pmem); printf("%d transient bats using %zu virtual memory (%zu malloced)\n", tn, tvm, tmem); printf("%d bats are \"hot\" (i.e. currently or recently used)\n", nh); + printf("%"PRIu32" bats are in global free list\n", BBP_nfree); } diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c --- a/gdk/gdk_system.c +++ b/gdk/gdk_system.c @@ -315,7 +315,6 @@ rm_mtthread(struct mtthread *t) struct mtthread **pt; assert(t != &mainthread); - BBPrelinquish(&t->freebats); thread_lock(); for (pt = &mtthreads; *pt && *pt != t; pt = &(*pt)->next) ; @@ -770,6 +769,7 @@ thread_starter(void *arg) (*self->thread_funcs[i].destroy)(self->thread_funcs[i].data); } free(self->thread_funcs); + BBPrelinquish(); ATOMIC_SET(&self->exited, 1); TRC_DEBUG(THRD, "Exit thread \"%s\"\n", self->threadname); return 0; /* NULL for pthreads, 0 for Windows */ diff --git a/gdk/gdk_system_private.h b/gdk/gdk_system_private.h --- a/gdk/gdk_system_private.h +++ b/gdk/gdk_system_private.h @@ -45,5 +45,5 @@ struct freebats { }; struct freebats *MT_thread_getfreebats(void) __attribute__((__visibility__("hidden"))); -void BBPrelinquish(struct freebats *t) +void BBPrelinquish(void) __attribute__((__visibility__("hidden"))); diff --git a/sql/test/transactions/Tests/All b/sql/test/transactions/Tests/All --- a/sql/test/transactions/Tests/All +++ b/sql/test/transactions/Tests/All @@ -8,3 +8,5 @@ view-deps chaining truncate-insert-restart update_drop_crash +KNOWNFAIL?update_drop_crash2 +KNOWNFAIL?insert_drop_crash diff --git a/sql/test/transactions/Tests/insert_drop_crash.test b/sql/test/transactions/Tests/insert_drop_crash.test new file mode 100644 --- /dev/null +++ b/sql/test/transactions/Tests/insert_drop_crash.test @@ -0,0 +1,29 @@ +statement ok +create table t1 (i int) + +statement ok +insert into t1 values (1), (2), (3), (9) + +@connection(id=drop) +statement ok +start transaction + +@connection(id=insert) +statement ok +start transaction + +@connection(id=insert) +statement ok +insert into t1 values (1), (2), (3), (9) + +@connection(id=drop) +statement ok +drop table t1 + +@connection(id=drop) +statement ok +commit + +@connection(id=insert) +statement ok +commit diff --git a/sql/test/transactions/Tests/update_drop_crash2.test b/sql/test/transactions/Tests/update_drop_crash2.test new file mode 100644 --- /dev/null +++ b/sql/test/transactions/Tests/update_drop_crash2.test @@ -0,0 +1,29 @@ +statement ok +create table t1 (i int) + +statement ok +insert into t1 values (1), (2), (3), (9) + +@connection(id=drop) +statement ok +start transaction + +@connection(id=update) +statement ok +start transaction + +@connection(id=update) +statement ok +update t1 set i=10 where i=2 + +@connection(id=drop) +statement ok +drop table t1 + +@connection(id=drop) +statement ok +commit + +@connection(id=update) +statement ok +commit diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in --- a/testing/Mtest.py.in +++ b/testing/Mtest.py.in @@ -1469,7 +1469,8 @@ def PerformDir(env, testdir, testlist, t crs.close() dbh.close() if maxid > nbats and maxid - nbats > 10000: - pSrvr.outfile.write(f'Too many free bats. Max ID = {maxid}, # used = {nbats}, diff = {maxid - nbats}.') + pSrvr.outfile.write(f'Too many free bats. Max ID = {maxid}, # used = {nbats}, diff = {maxid - nbats}.\n') + pSrvr.sendusr1() pSrvr.terminate() pSrvr = None if produce_html: @@ -2624,6 +2625,11 @@ class ServerClass: self.outfile.close() self.errfile.close() + def sendusr1(self): + if os.name != 'nt': + self.proc.send_signal(signal.SIGUSR1) + time.sleep(1) + def LaunchIt(self): global setpgrp _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org