diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp')
| -rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 26e9824cc57..3ed1d4e985b 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -36,6 +36,7 @@ #include <memory> #include "mongo/base/error_codes.h" +#include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/global_settings.h" #include "mongo/db/repl/repl_settings.h" #include "mongo/db/storage/journal_listener.h" @@ -241,10 +242,6 @@ void WiredTigerSessionCache::shuttingDown() { closeAll(); } -void WiredTigerSessionCache::restart() { - _shuttingDown.fetchAndBitAnd(~kShuttingDownMask); -} - bool WiredTigerSessionCache::isShuttingDown() { return _shuttingDown.load() & kShuttingDownMask; } @@ -291,26 +288,32 @@ void WiredTigerSessionCache::waitUntilDurable(OperationContext* opCtx, // waiters, as a log flush is much cheaper than a full checkpoint. if ((syncType == Fsync::kCheckpointStableTimestamp || syncType == Fsync::kCheckpointAll) && _engine->isDurable()) { - auto journalListener = [&]() -> JournalListener* { - // The JournalListener may not be set immediately, so we must check under a mutex so - // as not to access the variable while setting a JournalListener. A JournalListener - // is only allowed to be set once, so using the pointer outside of a mutex is safe. - stdx::unique_lock<Latch> lk(_journalListenerMutex); - return _journalListener; - }(); - boost::optional<JournalListener::Token> token; - if (journalListener && useListener == UseJournalListener::kUpdate) { - // Update a persisted value with the latest write timestamp that is safe across - // startup recovery in the repl layer. Then report that timestamp as durable to the - // repl layer below after we have flushed in-memory data to disk. - // Note: only does a write if primary, otherwise just fetches the timestamp. - token = journalListener->getToken(opCtx); - } + UniqueWiredTigerSession session = getSession(); + WT_SESSION* s = session->getSession(); + { + auto journalListener = [&]() -> JournalListener* { + // The JournalListener may not be set immediately, so we must check under a mutex so + // as not to access the variable while setting a JournalListener. A JournalListener + // is only allowed to be set once, so using the pointer outside of a mutex is safe. + stdx::unique_lock<Latch> lk(_journalListenerMutex); + return _journalListener; + }(); + boost::optional<JournalListener::Token> token; + if (journalListener && useListener == UseJournalListener::kUpdate) { + // Update a persisted value with the latest write timestamp that is safe across + // startup recovery in the repl layer. Then report that timestamp as durable to the + // repl layer below after we have flushed in-memory data to disk. + // Note: only does a write if primary, otherwise just fetches the timestamp. + token = journalListener->getToken(opCtx); + } - getKVEngine()->forceCheckpoint(syncType == Fsync::kCheckpointStableTimestamp); + auto config = syncType == Fsync::kCheckpointStableTimestamp ? "use_timestamp=true" + : "use_timestamp=false"; + invariantWTOK(s->checkpoint(s, config), s); - if (token) { - journalListener->onDurable(token.get()); + if (token) { + journalListener->onDurable(token.get()); + } } LOGV2_DEBUG(22418, 4, "created checkpoint (forced)"); return; |
