Changeset: d3f43b823539 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d3f43b823539 Modified Files: gdk/gdk_logger.c sql/ChangeLog.Dec2023 sql/backends/monet5/sql.c sql/storage/store.c Branch: Dec2023 Log Message:
When persiste_unlogged finds table is not yet persistent, it requests log rotation. diffs (67 lines): diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -3474,6 +3474,12 @@ log_tstart(logger *lg, bool flushnow, ul { rotation_lock(lg); if (flushnow) { + if (file_id == NULL) { + /* special case: ask store_manager to rotate log file */ + lg->file_age = 0; + rotation_unlock(lg); + return GDK_SUCCEED; + } /* I am now the exclusive flusher */ if (ATOMIC_GET(&lg->nr_flushers)) { /* I am waiting until all existing flushers are done */ diff --git a/sql/ChangeLog.Dec2023 b/sql/ChangeLog.Dec2023 --- a/sql/ChangeLog.Dec2023 +++ b/sql/ChangeLog.Dec2023 @@ -1,3 +1,12 @@ # ChangeLog file for sql # This file is updated with Maddlog +* Wed May 15 2024 Sjoerd Mullender <sjo...@acm.org> +- When sys.persist_unlogged is called for a table, it may return that + zero rows were persisted. If this is because the call was done too + early, i.e. the table was recently created and the write-ahead log + where this was logged has not been processed yet, the call will + request an immediate write-ahead log rotation. This means that the + WAL will be processed as soon as possible and a new call to + sys.persist_unlogged soon after will likely return a positive result. + 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 @@ -4436,6 +4436,16 @@ SQLpersist_unlogged(Client cntxt, MalBlk GDKfree(sizes); } count = d_bi.count; + } else { + /* special case of log_tstart: third arg == NULL with second arg + * true is request to rotate log file ASAP */ + store->logger_api.log_tstart(store, true, NULL); + /* special case for sql->debug: if 1024 bit is set, + * store_manager doesn't wait for 30 seconds of idle time before + * attempting to rotate */ + MT_lock_set(&store->flush); + store->debug |= 1024; + MT_lock_unset(&store->flush); } bat_iterator_end(&d_bi); diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -2420,7 +2420,10 @@ store_manager(sqlstore *store) for (;;) { const int idle = ATOMIC_GET(&GDKdebug) & FORCEMITOMASK ? 5000 : IDLE_TIME * 1000000; - if (store->debug&128 || ATOMIC_GET(&store->lastactive) + idle < (ATOMIC_BASE_TYPE) GDKusec()) { + /* if debug bit 1024 is set, attempt immediate log activation + * and clear the bit */ + if (store->debug&(128|1024) || ATOMIC_GET(&store->lastactive) + idle < (ATOMIC_BASE_TYPE) GDKusec()) { + store->debug &= ~1024; MT_lock_unset(&store->flush); store_lock(store); if (ATOMIC_GET(&store->nr_active) == 0) { _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org