diff options
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r-- | src/mongo/db/db_raii.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index e1030a6e45b..2c92beedcf8 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -99,7 +99,7 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, _autoColl.emplace(opCtx, nsOrUUID, collectionLockMode, viewMode, deadline); repl::ReplicationCoordinator* const replCoord = repl::ReplicationCoordinator::get(opCtx); - const auto readConcernLevel = opCtx->recoveryUnit()->getReadConcernLevel(); + const auto readConcernLevel = repl::ReadConcernArgs::get(opCtx).getLevel(); // Readers that opted-out of the PBWM lock before entering this function are either using // unenforced nesting of AutoGetCollectionForRead or are implicitly willing to read without a @@ -129,7 +129,9 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, bool readAtLastAppliedTimestamp = _shouldReadAtLastAppliedTimestamp(opCtx, nss, readConcernLevel); - opCtx->recoveryUnit()->setShouldReadAtLastAppliedTimestamp(readAtLastAppliedTimestamp); + if (readAtLastAppliedTimestamp) { + opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kLastApplied); + } // This timestamp could be earlier than the timestamp seen when the transaction is opened // because it is set asynchonously. This is not problematic because holding the collection @@ -143,8 +145,10 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, return; } + auto readSource = opCtx->recoveryUnit()->getTimestampReadSource(); invariant(lastAppliedTimestamp || - readConcernLevel == repl::ReadConcernLevel::kMajorityReadConcern); + readSource == RecoveryUnit::ReadSource::kMajorityCommitted); + invariant(readConcernLevel != repl::ReadConcernLevel::kSnapshotReadConcern); // Yield locks in order to do the blocking call below. _autoColl = boost::none; @@ -161,9 +165,10 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, << " on nss: " << nss.ns() << ", but future catalog changes are pending at time " << *minSnapshot << ". Trying again without reading at last-applied time."; _shouldNotConflictWithSecondaryBatchApplicationBlock = boost::none; + opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kNone); } - if (readConcernLevel == repl::ReadConcernLevel::kMajorityReadConcern) { + if (readSource == RecoveryUnit::ReadSource::kMajorityCommitted) { replCoord->waitUntilSnapshotCommitted(opCtx, *minSnapshot); uassertStatusOK(opCtx->recoveryUnit()->obtainMajorityCommittedSnapshot()); } |