summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2022-02-24 15:40:14 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-24 17:11:31 +0000
commitd5cda575e31df3d8c4a9fecb072ac0582748b576 (patch)
tree13eb9a2731109722f6374db895f1fb77a3db344e /src/mongo/db
parenta23d9da0518f79325b7dda04796dba0f856a08cd (diff)
downloadmongo-d5cda575e31df3d8c4a9fecb072ac0582748b576.tar.gz
SERVER-59342 Add killSessions and failover support to update shard key fsm testing
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/transaction_participant.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index ae2a12fe2e7..f932c572fbf 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -710,6 +710,16 @@ void TransactionParticipant::Participant::_beginOrContinueRetryableWrite(
retryableWriteTxnParticipantCatalog.addParticipant(*this);
} else {
// Retrying a retryable write.
+
+ // If this retryable write's transaction id has been converted to a transaction, and that
+ // transaction is in prepare, wait for it to exit prepare before throwing
+ // IncompleteTransactionHistory so the error response's operationTime is inclusive of the
+ // transaction's 2PC decision, guaranteeing causally consistent sessions will always read
+ // the transaction's writes.
+ uassert(ErrorCodes::PreparedTransactionInProgress,
+ "Retryable write that has been converted to a transaction is in prepare",
+ !o().txnState.isInSet(TransactionState::kPrepared));
+
uassert(ErrorCodes::IncompleteTransactionHistory,
"Cannot retry a retryable write that has been converted into a transaction",
o().txnState.isInRetryableWriteMode());