diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index 3521359..7113a0f 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -377,16 +377,17 @@ __wt_log_wrlsn(WT_SESSION_IMPL *session, WT_CONNECTION_IMPL *conn, WT_LOG* log, WT_LOG_WRLSN_ENTRY written[SLOT_POOL]; WT_LOGSLOT *slot; size_t written_i; - uint32_t i, save_i; + uint32_t i, save_i, max_i; i = 0; written_i = 0; *free_slot = NULL; + max_i = WT_MIN(log->max_used+1, SLOT_POOL-1); /* * Walk the array once saving any slots that are in the * WT_LOG_SLOT_WRITTEN state. */ - while (i < SLOT_POOL) { + while (i <= max_i) { save_i = i; slot = &log->slot_pool[i++]; if (!*free_slot && slot->slot_state==WT_LOG_SLOT_FREE) @@ -470,6 +471,12 @@ __wt_log_wrlsn(WT_SESSION_IMPL *session, WT_CONNECTION_IMPL *conn, WT_LOG* log, } + // adjust log->max_used + while (log->slot_pool[max_i].slot_state==WT_LOG_SLOT_FREE && max_i>0) + --max_i; + if (*free_slot) + max_i = WT_MAX(*free_slot - log->slot_pool, max_i); + log->max_used = max_i; return 0; } diff --git a/src/third_party/wiredtiger/src/include/log.h b/src/third_party/wiredtiger/src/include/log.h index 66f346e..90a7c9e 100644 --- a/src/third_party/wiredtiger/src/include/log.h +++ b/src/third_party/wiredtiger/src/include/log.h @@ -158,6 +158,7 @@ typedef struct { #define SLOT_ACTIVE 1 #define SLOT_POOL 128 uint32_t pool_index; /* Global pool index */ + uint32_t max_used; /* largest non-free slot */ WT_LOGSLOT *slot_array[SLOT_ACTIVE]; /* Active slots */ WT_LOGSLOT slot_pool[SLOT_POOL]; /* Pool of all slots */