Changeset: 1a0ab345fe4f for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1a0ab345fe4f Modified Files: gdk/gdk_orderidx.c Branch: Dec2016 Log Message:
Move unfix to outside the lock: it may cause deadlock (see comment). diffs (43 lines): diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c --- a/gdk/gdk_orderidx.c +++ b/gdk/gdk_orderidx.c @@ -121,6 +121,7 @@ BATorderidx(BAT *b, int stable) const char *nme; oid seq; BUN p, q; + BAT *bn = NULL; if (BATcheckorderidx(b)) return GDK_SUCCEED; @@ -155,7 +156,7 @@ BATorderidx(BAT *b, int stable) if (!BATtdense(b)) { /* we need to sort a copy of the column so as not to * change the original */ - BAT *bn = COLcopy(b, b->ttype, TRUE, TRANSIENT); + bn = COLcopy(b, b->ttype, TRUE, TRANSIENT); if (bn == NULL) { HEAPfree(m, 1); GDKfree(m); @@ -179,7 +180,11 @@ BATorderidx(BAT *b, int stable) BATcount(bn), Tsize(bn), SIZEOF_OID, bn->ttype); } - BBPunfix(bn->batCacheid); + /* we must unfix after releasing the lock since we + * might get deadlock otherwise (we're holding a lock + * based on b->batCacheid; unfix tries to get a lock + * based on bn->batCacheid, usually but (crucially) + * not always a different lock) */ } #ifdef PERSISTENTIDX @@ -202,6 +207,9 @@ BATorderidx(BAT *b, int stable) b->torderidx = m; MT_lock_unset(&GDKhashLock(b->batCacheid)); + if (bn) + BBPunfix(bn->batCacheid); + return GDK_SUCCEED; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list