diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-06-11 10:26:17 -0400 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-06-12 15:16:27 -0400 |
commit | 33660f28022d5d765a39c650b32fca8165be2d02 (patch) | |
tree | 16448dbe6f300efc08186edfd68df699554f5eb9 /src/mongo/db/db_raii.cpp | |
parent | 06d98ac518613723d3e5aa80b6877941e164699f (diff) | |
download | mongo-33660f28022d5d765a39c650b32fca8165be2d02.tar.gz |
SERVER-35000 Distinguish readSource noTimestamp from readSource unset
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r-- | src/mongo/db/db_raii.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp index 0b95c28efe4..529743fbfc4 100644 --- a/src/mongo/db/db_raii.cpp +++ b/src/mongo/db/db_raii.cpp @@ -87,8 +87,6 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, const NamespaceStringOrUUID& nsOrUUID, AutoGetCollection::ViewMode viewMode, Date_t deadline) { - bool optedOutOfPbwmLock = !opCtx->lockState()->shouldConflictWithSecondaryBatchApplication(); - // Don't take the ParallelBatchWriterMode lock when the server parameter is set and our // storage engine supports snapshot reads. if (allowSecondaryReadsDuringBatchApplication.load() && @@ -98,15 +96,14 @@ AutoGetCollectionForRead::AutoGetCollectionForRead(OperationContext* opCtx, const auto collectionLockMode = getLockModeForQuery(opCtx); _autoColl.emplace(opCtx, nsOrUUID, collectionLockMode, viewMode, deadline); + // If the read source is explicitly set to kNoTimestamp, we read the most up to date data and do + // not consider reading at last applied (e.g. FTDC needs that). + if (opCtx->recoveryUnit()->getTimestampReadSource() == RecoveryUnit::ReadSource::kNoTimestamp) + return; + repl::ReplicationCoordinator* const replCoord = repl::ReplicationCoordinator::get(opCtx); 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 - // timestamp, like internal operations such as rollback. - if (optedOutOfPbwmLock && readConcernLevel == repl::ReadConcernLevel::kLocalReadConcern) - return; - // If the collection doesn't exist or disappears after releasing locks and waiting, there is no // need to check for pending catalog changes. while (auto coll = _autoColl->getCollection()) { @@ -165,7 +162,7 @@ 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); + opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kUnset); } if (readSource == RecoveryUnit::ReadSource::kMajorityCommitted) { |