diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-09-18 13:16:12 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-21 14:53:54 +0000 |
commit | b1d4d55ec0af8a7b2f5cbefdb8dd590607dfe732 (patch) | |
tree | eb2d56fac92c3a9d164ec2a8195296837193f86e /src | |
parent | 268081db9538c5db216c83a1b63f83540be0075c (diff) | |
download | mongo-b1d4d55ec0af8a7b2f5cbefdb8dd590607dfe732.tar.gz |
SERVER-50915 fsyncLock must not take a stable checkpoint when majority read concern is off
Diffstat (limited to 'src')
4 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index 3b1f1ca9c87..fc66c03da01 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -330,9 +330,7 @@ void ReplicationRecoveryImpl::_recoverFromUnstableCheckpoint(OperationContext* o // datafiles contain any writes that were taken before the crash. _consistencyMarkers->setAppliedThrough(opCtx, topOfOplog); - // Force the set `appliedThrough` to become durable on disk in a checkpoint. This method would - // typically take a stable checkpoint, but because we're starting up from a checkpoint that - // has no checkpoint timestamp, the stable checkpoint "degrades" into an unstable checkpoint. + // Force the set `appliedThrough` to become durable on disk in a checkpoint. // // Not waiting for checkpoint durability here can result in a scenario where the node takes // writes and persists them to the oplog, but crashes before a stable checkpoint persists a diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 5fc2d6ad474..e80512e63fc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -939,8 +939,8 @@ int WiredTigerKVEngine::flushAllFiles(OperationContext* opCtx, bool sync) { } syncSizeInfo(false); const bool forceCheckpoint = true; - // If there's no journal, we must take a full checkpoint. - const bool stableCheckpoint = _durable; + // If there's no journal or if majority read concern is off, we must take a full checkpoint. + const bool stableCheckpoint = _durable && serverGlobalParams.enableMajorityReadConcern; _sessionCache->waitUntilDurable(forceCheckpoint, stableCheckpoint); return 1; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 1adbcfcc530..7ec4e21c916 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -288,7 +288,7 @@ bool WiredTigerRecoveryUnit::waitUntilDurable() { bool WiredTigerRecoveryUnit::waitUntilUnjournaledWritesDurable() { invariant(!_inUnitOfWork); const bool forceCheckpoint = true; - const bool stableCheckpoint = true; + const bool stableCheckpoint = serverGlobalParams.enableMajorityReadConcern; // Calling `waitUntilDurable` with `forceCheckpoint` set to false only performs a log // (journal) flush, and thus has no effect on unjournaled writes. Setting `forceCheckpoint` to // true will lock in stable writes to unjournaled tables. diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp index 1e885814cf3..8219cf91808 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp @@ -244,6 +244,10 @@ void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint, bool stableC return; } + if (stableCheckpoint) { + invariant(serverGlobalParams.enableMajorityReadConcern); + } + const int shuttingDown = _shuttingDown.fetchAndAdd(1); ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); }); |