summaryrefslogtreecommitdiff
path: root/src/mongo/db/read_concern.cpp
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2018-09-28 10:37:14 -0400
committerSamy Lanka <samy.lanka@mongodb.com>2018-10-01 16:27:56 -0400
commitf7b229af67e5d2e8f77009563347c0220988e6b2 (patch)
treea2d1f1ae5022312c798714e730a54faeb45119cb /src/mongo/db/read_concern.cpp
parent3c2eb809fb7f6924612c1900e57cc456bcbb4983 (diff)
downloadmongo-f7b229af67e5d2e8f77009563347c0220988e6b2.tar.gz
SERVER-37030 Make internal reads ignore prepare conflicts by default
Diffstat (limited to 'src/mongo/db/read_concern.cpp')
-rw-r--r--src/mongo/db/read_concern.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/read_concern.cpp b/src/mongo/db/read_concern.cpp
index 6184548f7b0..d2f18637fac 100644
--- a/src/mongo/db/read_concern.cpp
+++ b/src/mongo/db/read_concern.cpp
@@ -206,10 +206,12 @@ Status waitForReadConcern(OperationContext* opCtx,
bool allowAfterClusterTime) {
// If we are in a direct client within a transaction, then we may be holding locks, so it is
// illegal to wait for read concern. This is fine, since the outer operation should have handled
- // waiting for read concern.
+ // waiting for read concern. We don't want to ignore prepare conflicts because snapshot reads
+ // should block on prepared transactions.
auto txnParticipant = TransactionParticipant::get(opCtx);
if (opCtx->getClient()->isInDirectClient() && txnParticipant &&
txnParticipant->inMultiDocumentTransaction()) {
+ opCtx->recoveryUnit()->setIgnorePrepared(false);
return Status::OK();
}
@@ -304,6 +306,8 @@ Status waitForReadConcern(OperationContext* opCtx,
}
if (atClusterTime) {
+ opCtx->recoveryUnit()->setIgnorePrepared(false);
+
// TODO(SERVER-34620): We should be using Session::setSpeculativeTransactionReadOpTime when
// doing speculative execution with atClusterTime.
opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kProvided,
@@ -339,12 +343,12 @@ Status waitForReadConcern(OperationContext* opCtx,
}
// Only snapshot, linearizable and afterClusterTime reads should block on prepared transactions.
- // We don't ignore prepare conflicts if we are in a direct client in case this overrides
- // behavior set by a higher-level operation.
if (readConcernArgs.getLevel() != repl::ReadConcernLevel::kSnapshotReadConcern &&
readConcernArgs.getLevel() != repl::ReadConcernLevel::kLinearizableReadConcern &&
- !afterClusterTime && !atClusterTime && !opCtx->getClient()->isInDirectClient()) {
+ !afterClusterTime && !atClusterTime) {
opCtx->recoveryUnit()->setIgnorePrepared(true);
+ } else {
+ opCtx->recoveryUnit()->setIgnorePrepared(false);
}
return Status::OK();