Changeset: 57c9d4bcc48b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/57c9d4bcc48b Modified Files: gdk/gdk_bbp.c gdk/gdk_storage.c sql/server/sql_mvc.c sql/storage/store.c Branch: default Log Message:
Merge with Jan2022 branch. diffs (190 lines): diff --git a/gdk/ChangeLog.Jan2022 b/gdk/ChangeLog.Jan2022 --- a/gdk/ChangeLog.Jan2022 +++ b/gdk/ChangeLog.Jan2022 @@ -1,6 +1,15 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Thu Jul 28 2022 Sjoerd Mullender <sjo...@acm.org> +- Fixed an off-by-one error in the logger which caused older log files + to stick around longer in the write-ahead log than necessary. +- When an empty BAT is committed, skip writing (and synchronizing to + disk) the heap (tail and theap) files and write 0 for their sizes to + the BBP.dir file. When reading the BBP.dir file, if an empty BAT is + encountered, set the sizes of those files to 0. This fixes potential + issues during startup of the server (BBPcheckbats reporting errors). + * Wed Jun 22 2022 Sjoerd Mullender <sjo...@acm.org> - Make sure heap files of transient bats get deleted when the bat is destroyed. If the bat was a partial view (sharing the vheap but not diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -3195,10 +3195,6 @@ BBPdestroy(BAT *b) bat tp = VIEWtparent(b); bat vtp = VIEWvtparent(b); - HASHdestroy(b); - IMPSdestroy(b); - OIDXdestroy(b); - PROPdestroy_nolock(b); if (tp == 0) { /* bats that get destroyed must unfix their atoms */ gdk_return (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix; @@ -3213,17 +3209,15 @@ BBPdestroy(BAT *b) } } } - if (b->theap) { - assert(tp != 0 || (ATOMIC_GET(&b->theap->refs) & HEAPREFS) == 1); - HEAPdecref(b->theap, tp == 0); + if (tp != 0) { + HEAPdecref(b->theap, false); b->theap = NULL; } - if (b->tvheap) { - assert(vtp != 0 || (ATOMIC_GET(&b->tvheap->refs) & HEAPREFS) == 1); - HEAPdecref(b->tvheap, vtp == 0); + if (vtp != 0) { + HEAPdecref(b->tvheap, false); b->tvheap = NULL; } - b->batCopiedtodisk = false; + BATdelete(b); BBPclear(b->batCacheid, true); /* if destroyed; de-register from BBP */ @@ -3794,6 +3788,8 @@ BBPcheckBBPdir(bool subcommit) case 0: /* end of file */ fclose(fp); + /* don't leak errors, this is just debug code */ + GDKclrerr(); return; case 1: /* successfully read an entry */ diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c --- a/gdk/gdk_storage.c +++ b/gdk/gdk_storage.c @@ -867,8 +867,11 @@ BATdelete(BAT *b) { bat bid = b->batCacheid; BAT *loaded = BBP_cache(bid); + char o[10]; + char *f; assert(bid > 0); + snprintf(o, sizeof(o), "%o", (unsigned) bid); if (loaded) { b = loaded; } @@ -877,9 +880,29 @@ BATdelete(BAT *b) OIDXdestroy(b); PROPdestroy_nolock(b); STRMPdestroy(b); - HEAPfree(b->theap, true); - if (b->tvheap) + if (b->theap) { + HEAPfree(b->theap, true); + if ((f = GDKfilepath(b->theap->farmid, BAKDIR, o, "tail1")) != NULL) { + MT_remove(f); + size_t i = strlen(f) - 1; + f[i] = '2'; + MT_remove(f); +#if SIZEOF_VAR_T == 8 + f[i] = '4'; + MT_remove(f); +#endif + f[i] = '\0'; + MT_remove(f); + GDKfree(f); + } + } + if (b->tvheap) { HEAPfree(b->tvheap, true); + if ((f = GDKfilepath(b->theap->farmid, BAKDIR, o, "theap")) != NULL) { + MT_remove(f); + GDKfree(f); + } + } b->batCopiedtodisk = false; } diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c --- a/sql/server/sql_mvc.c +++ b/sql/server/sql_mvc.c @@ -566,11 +566,10 @@ mvc_commit(mvc *m, int chain, const char while (tr->parent != NULL && ok == SQL_OK) { if ((ok = sql_trans_commit(tr)) == SQL_ERR) GDKfatal("%s transaction commit failed; exiting (kernel error: %s)", operation, GDKerrbuf); - tr = sql_trans_destroy(tr); + m->session->tr = tr = sql_trans_destroy(tr); } while (tr->parent != NULL) - tr = sql_trans_destroy(tr); - m->session->tr = tr; + m->session->tr = tr = sql_trans_destroy(tr); if (ok != SQL_OK) msg = createException(SQL, "sql.commit", SQLSTATE(40001) "%s transaction is aborted because of concurrency conflicts, will ROLLBACK instead", operation); } @@ -644,7 +643,7 @@ mvc_rollback(mvc *m, int chain, const ch /* make sure we do not reuse changed data */ if (!list_empty(tr->changes)) tr->status = 1; - tr = sql_trans_destroy(tr); + m->session->tr = tr = sql_trans_destroy(tr); } /* start a new transaction after rolling back */ if (!(m->session->tr = tr = sql_trans_create(m->store, tr, name))) { @@ -661,8 +660,7 @@ mvc_rollback(mvc *m, int chain, const ch } else { /* first release all intermediate savepoints */ while (tr->parent != NULL) - tr = sql_trans_destroy(tr); - m->session-> tr = tr; + m->session-> tr = tr = sql_trans_destroy(tr); /* make sure we do not reuse changed data */ if (!list_empty(tr->changes)) tr->status = 1; @@ -720,10 +718,9 @@ mvc_release(mvc *m, const char *name) /* commit all intermediate savepoints */ if (sql_trans_commit(tr) != SQL_OK) GDKfatal("release savepoints should not fail"); - tr = sql_trans_destroy(tr); + m->session->tr = tr = sql_trans_destroy(tr); } - _DELETE(tr->name); /* name will no longer be used */ - m->session->tr = tr; + _DELETE(m->session->tr->name); /* name will no longer be used */ m->session->status = tr->status; if (!(m->session->schema = find_sql_schema(m->session->tr, m->session->schema_name))) { msg = createException(SQL, "sql.release", SQLSTATE(40000) "RELEASE: finished successfully, but the session's schema could not be found on the current transaction"); @@ -841,7 +838,7 @@ mvc_reset(mvc *m, bstream *rs, stream *w if (tr && tr->parent) { assert(m->session->tr->active == 0); while (tr->parent->parent != NULL) - tr = sql_trans_destroy(tr); + m->session->tr = tr = sql_trans_destroy(tr); } reset = sql_session_reset(m->session, 1 /*autocommit on*/); if (tr && !reset) @@ -899,7 +896,7 @@ mvc_destroy(mvc *m) if (m->session->tr->active) (void)sql_trans_end(m->session, SQL_ERR); while (tr->parent) - tr = sql_trans_destroy(tr); + m->session->tr = tr = sql_trans_destroy(tr); } sql_session_destroy(m->session); diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -7030,7 +7030,6 @@ sql_trans_begin(sql_session *s) return -3; } tr->active = 1; - s->tr = tr; (void) ATOMIC_INC(&store->nr_active); list_append(store->active, s); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org