summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2021-09-09 19:16:11 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-05 16:10:09 +0000
commitec3acbdb7580d99f524f2893abe153d6aae62e75 (patch)
tree95fde583ef29a4e2e35633f3a7e2f05a8c748a5e
parentb3cc5b18bda3cd24465126f1603fa54b2ea7926e (diff)
downloadmongo-ec3acbdb7580d99f524f2893abe153d6aae62e75.tar.gz
SERVER-58183 Ensure that we ignore prepare conflicts when applying prepare transaction oplog entries
(cherry picked from commit ea2ea50017f76adf68ca3cb385546774a251c42e) (cherry picked from commit 5e553f1e34dddb6242b936c0f1e00a8294a39747)
-rw-r--r--src/mongo/db/repl/transaction_oplog_application.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp
index 8a280a9d71a..8090164d85e 100644
--- a/src/mongo/db/repl/transaction_oplog_application.cpp
+++ b/src/mongo/db/repl/transaction_oplog_application.cpp
@@ -430,6 +430,10 @@ Status _applyPrepareTransaction(OperationContext* opCtx,
auto txnParticipant = TransactionParticipant::get(opCtx);
+ // We reset the recovery unit on retries, so make sure that we ignore prepare conflicts.
+ opCtx->recoveryUnit()->setPrepareConflictBehavior(
+ PrepareConflictBehavior::kIgnoreConflictsAllowWrites);
+
// Release the WUOW, transaction lock resources and abort storage transaction so that the
// writeConflictRetry loop will be able to retry applying transactional ops on WCE error.
auto abortOnError = makeGuard([&txnParticipant, opCtx] {