diff options
author | Louis Williams <louis.williams@mongodb.com> | 2019-03-14 12:34:23 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2019-03-19 17:03:40 -0400 |
commit | 197233a97c2a8859b82ba1ffeac97ba2719f6470 (patch) | |
tree | 56d7bfb37a6957c27bc7ee13c062086742a59fa9 /src/mongo/db/repl | |
parent | 81d045a17ddf08e9f0eb7f30f96b45a352fab5cc (diff) | |
download | mongo-197233a97c2a8859b82ba1ffeac97ba2719f6470.tar.gz |
SERVER-39074 All operations enforce prepare conflicts by default
Prepare conflicts may only be safely ignored when a command can
guarantee it does not perform writes. Prepare conflicts are ignored when
the read concern is local, available, or majority and the command is
aggregate, count, distinct, find, getMore, or group. Aggregate is a
special case because it may perform writes to an output collection, but
it enables prepare conflict enforcement before doing so.
Additionally, connections from a DBDirectClient inherit the
ignore_prepare state from their parent operation.
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/replication_recovery.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index 0b8f5186de7..2f797d7be53 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -310,6 +310,10 @@ void ReplicationRecoveryImpl::_reconstructPreparedTransactions(OperationContext* // Snapshot transaction can never conflict with the PBWM lock. newOpCtx->lockState()->setShouldConflictWithSecondaryBatchApplication(false); + // TODO: SERVER-40177 This should be removed once it is guaranteed operations applied on + // recovering nodes cannot encounter unnecessary prepare conflicts. + newOpCtx->recoveryUnit()->setIgnorePrepared(true); + // Checks out the session, applies the operations and prepares the transactions. uassertStatusOK(applyRecoveredPrepareTransaction(newOpCtx.get(), prepareOplogEntry)); } diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index b528223341d..20632cf225d 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -1108,6 +1108,10 @@ Status multiSyncApply(OperationContext* opCtx, // Explicitly start future read transactions without a timestamp. opCtx->recoveryUnit()->setTimestampReadSource(RecoveryUnit::ReadSource::kNoTimestamp); + // TODO: SERVER-40177 This should be removed once it is guaranteed operations applied on + // secondaries cannot encounter unnecessary prepare conflicts. + opCtx->recoveryUnit()->setIgnorePrepared(true); + ApplierHelpers::stableSortByNamespace(ops); // Assume we are recovering if oplog writes are disabled in the options. |