diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2019-08-13 12:48:25 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2019-08-23 14:30:06 -0400 |
commit | 266e079792be38e67442ef5fb2dbd557a6ca694d (patch) | |
tree | 9d47e3010299be13a7a37cc33fbaec7356c53b89 /src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp | |
parent | f98b80b33347b52cc4cd7b11880ac3057a32359f (diff) | |
download | mongo-266e079792be38e67442ef5fb2dbd557a6ca694d.tar.gz |
SERVER-42221 Add concurrency control to checkpoint requests and expose it to the validation cmd code layer
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp index e3ec7e9097d..2edf06fb8a2 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp @@ -33,6 +33,7 @@ #include <cstring> +#include "mongo/db/concurrency/lock_state.h" #include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h" #include "mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h" #include "mongo/db/storage/wiredtiger/wiredtiger_util.h" @@ -162,6 +163,17 @@ void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* ses // forward cursors. The timestamp is used to hide oplog entries that might be committed but // have uncommitted entries ahead of them. while (true) { + auto opCtx = cc().makeOperationContext(); + + // This thread is started before we finish creating the StorageEngine and consequently + // makeOperationContext() returns an OperationContext with a LockerNoop. Rather than trying + // to refactor the code to start this thread after the StorageEngine is fully instantiated, + // we will use this temporary hack to give the opCtx a real Locker. + // + // TODO (SERVER-41392): the Replicate Before Journaling project will be removing the + // waitUntilDurable() call requiring an opCtx parameter. + opCtx->swapLockState(std::make_unique<LockerImpl>()); + stdx::unique_lock<stdx::mutex> lk(_oplogVisibilityStateMutex); { MONGO_IDLE_THREAD_BLOCK; @@ -219,7 +231,7 @@ void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* ses // In order to avoid oplog holes after an unclean shutdown, we must ensure this proposed // oplog read timestamp's documents are durable before publishing that timestamp. - sessionCache->waitUntilDurable(/*forceCheckpoint=*/false, false); + sessionCache->waitUntilDurable(opCtx.get(), /*forceCheckpoint=*/false, false); lk.lock(); // Publish the new timestamp value. Avoid going backward. |