Skip to content

Commit

Permalink
SERVER-38218 AutoGetCollection doesn't need to call getPointInTimeRea…
Browse files Browse the repository at this point in the history
…dTimestamp for non snapshot read concern levels
  • Loading branch information
will62794 committed Nov 21, 2018
1 parent cce280f commit 6c2879f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/mongo/db/catalog_raii.cpp
Expand Up @@ -104,18 +104,20 @@ AutoGetCollection::AutoGetCollection(OperationContext* opCtx,
// pending catalog changes. Instead, we must return an error in such situations. We ignore
// this restriction for the oplog, since it never has pending catalog changes.
auto readConcernLevel = repl::ReadConcernArgs::get(opCtx).getLevel();
auto mySnapshot = opCtx->recoveryUnit()->getPointInTimeReadTimestamp();
if (readConcernLevel == repl::ReadConcernLevel::kSnapshotReadConcern && mySnapshot &&
if (readConcernLevel == repl::ReadConcernLevel::kSnapshotReadConcern &&
_resolvedNss != NamespaceString::kRsOplogNamespace) {
auto minSnapshot = _coll->getMinimumVisibleSnapshot();
uassert(
ErrorCodes::SnapshotUnavailable,
str::stream() << "Unable to read from a snapshot due to pending collection catalog "
"changes; please retry the operation. Snapshot timestamp is "
<< mySnapshot->toString()
<< ". Collection minimum is "
<< minSnapshot->toString(),
!minSnapshot || *mySnapshot >= *minSnapshot);
auto mySnapshot = opCtx->recoveryUnit()->getPointInTimeReadTimestamp();
if (mySnapshot) {
auto minSnapshot = _coll->getMinimumVisibleSnapshot();
uassert(ErrorCodes::SnapshotUnavailable,
str::stream()
<< "Unable to read from a snapshot due to pending collection catalog "
"changes; please retry the operation. Snapshot timestamp is "
<< mySnapshot->toString()
<< ". Collection minimum is "
<< minSnapshot->toString(),
!minSnapshot || *mySnapshot >= *minSnapshot);
}
}

// If the collection exists, there is no need to check for views.
Expand Down

0 comments on commit 6c2879f

Please sign in to comment.