summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2018-04-25 18:26:29 -0400
committerLouis Williams <louis.williams@mongodb.com>2018-05-15 13:36:10 -0400
commit6d2de545a7cfcf4ab23dcf73426a1d50896d6d0c (patch)
tree87b85ca0534101cd8480b25c5c32b8b7fff40d60 /src/mongo/db/db_raii.cpp
parent088097b7abadc753da184124c6240ede86d08178 (diff)
downloadmongo-6d2de545a7cfcf4ab23dcf73426a1d50896d6d0c.tar.gz
SERVER-34443 Refactor WiredTigerRecoveryUnit and WiredTigerSnapshotManager. An enum is now used to indicate at which time to read on a RecoveryUnit.
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp13
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());
}