summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction_participant.cpp
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-07-25 00:51:10 -0400
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-07-25 16:51:46 -0400
commit9dd11ed72971d6d5c00b9208e0200b6895658a87 (patch)
tree57beb885c237fa9290f203ba2459f1f984b1c3d8 /src/mongo/db/transaction_participant.cpp
parent917d338c4bf52dc8dce2c0e585a676385e81ed1c (diff)
downloadmongo-9dd11ed72971d6d5c00b9208e0200b6895658a87.tar.gz
SERVER-42398 On primary, abortTransaction and commitTransaction commands should not acquire ticket irrespective of the prepared state.
Diffstat (limited to 'src/mongo/db/transaction_participant.cpp')
-rw-r--r--src/mongo/db/transaction_participant.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp
index 840448371c9..5d9b45eeda0 100644
--- a/src/mongo/db/transaction_participant.cpp
+++ b/src/mongo/db/transaction_participant.cpp
@@ -916,8 +916,6 @@ void TransactionParticipant::Participant::_releaseTransactionResourcesToOpCtx(
tempTxnResourceStash->release(opCtx);
releaseOnError.dismiss();
-
- invariant(opCtx->lockState()->shouldAcquireTicket() || o().txnState.isPrepared());
}
void TransactionParticipant::Participant::unstashTransactionResources(OperationContext* opCtx,
@@ -941,10 +939,14 @@ void TransactionParticipant::Participant::unstashTransactionResources(OperationC
// Primaries should respect the transaction lock timeout, since it can prevent
// the transaction from making progress.
maxLockTimeout = MaxLockTimeout::kAllowed;
+ // commitTransaction and abortTransaction commands can skip ticketing mechanism as they
+ // don't acquire any new storage resources (except writing to oplog) but they release
+ // any claimed storage resources.
// Prepared transactions should not acquire ticket. Else, it can deadlock with other
// non-transactional operations that have exhausted the write tickets and are blocked on
// them due to prepare or lock conflict.
- if (o().txnState.isPrepared()) {
+ if (o().txnState.isPrepared() || cmdName == "commitTransaction" ||
+ cmdName == "abortTransaction") {
acquireTicket = AcquireTicket::kSkip;
}
} else {