summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index bd906e36f15..b0d94e170ec 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -497,9 +497,12 @@ AutoGetCollectionForReadBase<AutoGetCollectionType, EmplaceAutoCollFunc>::
// Once we have our locks, check whether or not we should override the ReadSource that was
// set before acquiring locks.
- const bool shouldReadAtLastApplied = SnapshotHelper::changeReadSourceIfNeeded(opCtx, nss);
- // Update readSource in case it was updated.
- readSource = opCtx->recoveryUnit()->getTimestampReadSource();
+ auto [newReadSource, shouldReadAtLastApplied] =
+ SnapshotHelper::shouldChangeReadSource(opCtx, nss);
+ if (newReadSource) {
+ opCtx->recoveryUnit()->setTimestampReadSource(*newReadSource);
+ readSource = *newReadSource;
+ }
const auto readTimestamp = opCtx->recoveryUnit()->getPointInTimeReadTimestamp(opCtx);
if (readTimestamp && afterClusterTime) {
@@ -699,7 +702,11 @@ void AutoGetCollectionForReadLockFree::EmplaceHelper::emplace(
// replication state may have changed, invalidating our current choice of
// ReadSource. Using the same preconditions, change our ReadSource if necessary.
if (coll) {
- SnapshotHelper::changeReadSourceIfNeeded(opCtx, coll->ns());
+ auto [newReadSource, _] =
+ SnapshotHelper::shouldChangeReadSource(opCtx, coll->ns());
+ if (newReadSource) {
+ opCtx->recoveryUnit()->setTimestampReadSource(*newReadSource);
+ }
}
return std::make_pair(coll, /* isView */ false);
@@ -936,18 +943,6 @@ const NamespaceString& AutoGetCollectionForReadCommandMaybeLockFree::getNss() co
}
}
-query_shape::CollectionType AutoGetCollectionForReadCommandMaybeLockFree::getCollectionType()
- const {
- if (auto&& view = getView()) {
- return view->timeseries() ? query_shape::CollectionType::kTimeseries
- : query_shape::CollectionType::kView;
- }
- auto&& collection = getCollection();
- return collection ? query_shape::CollectionType::kCollection
- : query_shape::CollectionType::kNonExistent;
-}
-
-
bool AutoGetCollectionForReadCommandMaybeLockFree::isAnySecondaryNamespaceAViewOrSharded() const {
return _autoGet ? _autoGet->isAnySecondaryNamespaceAViewOrSharded()
: _autoGetLockFree->isAnySecondaryNamespaceAViewOrSharded();