Changeset: a86c2ee305f2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/a86c2ee305f2 Modified Files: gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_group.c Branch: default Log Message:
Merge with Dec2023 branch. diffs (175 lines): diff --git a/gdk/ChangeLog.Dec2023 b/gdk/ChangeLog.Dec2023 --- a/gdk/ChangeLog.Dec2023 +++ b/gdk/ChangeLog.Dec2023 @@ -1,3 +1,7 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Mon Mar 18 2024 Sjoerd Mullender <sjo...@acm.org> +- Fixed a couple of deadlock situations, one actually observed, one + never observed. + diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -814,8 +814,7 @@ COLcopy(BAT *b, int tt, bool writable, r return NULL; } - MT_lock_set(&b->theaplock); - bi = bat_iterator_nolock(b); + bi = bat_iterator(b); /* first try case (1); create a view, possibly with different * atom-types */ @@ -823,12 +822,12 @@ COLcopy(BAT *b, int tt, bool writable, r role == TRANSIENT && bi.restricted == BAT_READ && ATOMstorage(b->ttype) != TYPE_msk && /* no view on TYPE_msk */ - (!VIEWtparent(b) || - BBP_desc(VIEWtparent(b))->batRestricted == BAT_READ)) { - MT_lock_unset(&b->theaplock); + (bi.h == NULL || + bi.h->parentid == b->batCacheid || + BBP_desc(bi.h->parentid)->batRestricted == BAT_READ)) { bn = VIEWcreate(b->hseqbase, b); if (bn == NULL) { - return NULL; + goto bunins_failed; } if (tt != bn->ttype) { bn->ttype = tt; @@ -840,6 +839,7 @@ COLcopy(BAT *b, int tt, bool writable, r } bn->tseqbase = ATOMtype(tt) == TYPE_oid ? bi.tseq : oid_nil; } + bat_iterator_end(&bi); return bn; } else { /* check whether we need case (4); BUN-by-BUN copy (by @@ -867,8 +867,7 @@ COLcopy(BAT *b, int tt, bool writable, r bn = COLnew2(b->hseqbase, tt, bi.count, role, bi.width); if (bn == NULL) { - MT_lock_unset(&b->theaplock); - return NULL; + goto bunins_failed; } if (bn->tvheap != NULL && bn->tvheap->base == NULL) { /* this combination can happen since the last @@ -906,15 +905,17 @@ COLcopy(BAT *b, int tt, bool writable, r bn->batCapacity = 0; } else if (BATatoms[tt].atomFix || tt != TYPE_void || ATOMextern(tt)) { /* case (4): one-by-one BUN insert (really slow) */ - BUN p, q; + QryCtx *qry_ctx = MT_thread_get_qry_ctx(); + qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0}; - BATloop(b, p, q) { + TIMEOUT_LOOP_IDX_DECL(p, bi.count, qry_ctx) { const void *t = BUNtail(bi, p); if (bunfastapp_nocheck(bn, t) != GDK_SUCCEED) { goto bunins_failed; } } + TIMEOUT_CHECK(qry_ctx, GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed, qry_ctx)); bn->theap->dirty |= bi.count > 0; } else if (tt != TYPE_void && bi.type == TYPE_void) { /* case (4): optimized for unary void @@ -951,7 +952,7 @@ COLcopy(BAT *b, int tt, bool writable, r } else { BATtseqbase(bn, oid_nil); } - BATkey(bn, BATtkey(b)); + BATkey(bn, bi.key); bn->tsorted = bi.sorted; bn->trevsorted = bi.revsorted; bn->tnorevsorted = bi.norevsorted; @@ -969,7 +970,7 @@ COLcopy(BAT *b, int tt, bool writable, r bn->tunique_est = bi.unique_est; } else if (ATOMstorage(tt) == ATOMstorage(b->ttype) && ATOMcompare(tt) == ATOMcompare(b->ttype)) { - BUN h = BATcount(b); + BUN h = bi.count; bn->tsorted = bi.sorted; bn->trevsorted = bi.revsorted; BATkey(bn, bi.key); @@ -1006,14 +1007,14 @@ COLcopy(BAT *b, int tt, bool writable, r bn->trevsorted = ATOMlinear(b->ttype); bn->tkey = true; } + bat_iterator_end(&bi); if (!writable) bn->batRestricted = BAT_READ; TRC_DEBUG(ALGO, ALGOBATFMT " -> " ALGOBATFMT "\n", ALGOBATPAR(b), ALGOBATPAR(bn)); - MT_lock_unset(&b->theaplock); return bn; bunins_failed: - MT_lock_unset(&b->theaplock); + bat_iterator_end(&bi); BBPreclaim(bn); return NULL; } diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -739,6 +739,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool atomcmp(BUNtail(ni, ni.minpos), minbound) < 0) { assert(0); GDKerror("value out of bounds\n"); + MT_lock_unset(&b->theaplock); goto bailout; } } @@ -750,6 +751,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool atomcmp(BUNtail(ni, ni.maxpos), maxbound) >= 0) { assert(0); GDKerror("value out of bounds\n"); + MT_lock_unset(&b->theaplock); goto bailout; } } @@ -802,6 +804,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool if (minbound && n->tseqbase + ci.seq - hseq < *(const oid *)minbound) { assert(0); GDKerror("value not within bounds\n"); + MT_lock_unset(&b->theaplock); goto bailout; } BATtseqbase(b, n->tseqbase + ci.seq - hseq); @@ -809,6 +812,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool if (maxbound && b->tseqbase + BATcount(b) + ci.ncand >= *(const oid *)maxbound) { assert(0); GDKerror("value not within bounds\n"); + MT_lock_unset(&b->theaplock); goto bailout; } BATsetcount(b, BATcount(b) + ci.ncand); @@ -821,6 +825,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool if (notnull) { assert(0); GDKerror("NULL value not within bounds\n"); + MT_lock_unset(&b->theaplock); goto bailout; } BATtseqbase(b, oid_nil); diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c +++ b/gdk/gdk_group.c @@ -848,14 +848,12 @@ BATgroup_internal(BAT **groups, BAT **ex maxgrps = b->thash->nunique; MT_rwlock_rdunlock(&b->thashlock); if (maxgrps == BUN_NONE) { - MT_lock_set(&b->theaplock); if (bi.unique_est != 0) { maxgrps = (BUN) bi.unique_est; if (maxgrps > ci.ncand) maxgrps = ci.ncand; } else maxgrps = ci.ncand / 10; - MT_lock_unset(&b->theaplock); } if (!is_oid_nil(maxgrp) && maxgrps < maxgrp) maxgrps += maxgrp; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org