diff options
author | Pavithra Vetriselvan <pavithra.vetriselvan@mongodb.com> | 2019-09-24 02:03:40 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-24 02:03:40 +0000 |
commit | 86792e81d6e1b348ec102bb22039d2a5e5f5d7e5 (patch) | |
tree | 9f0a3dcb6c7df33a0dce2a7737c1ea8f5bc10598 | |
parent | fc6ae12e7096f73f34969537324084b10d9c11ce (diff) | |
download | mongo-86792e81d6e1b348ec102bb22039d2a5e5f5d7e5.tar.gz |
SERVER-39614 replace inActiveOrKilledMultiDocumentTransaction with inMultiDocumentTransaction
(cherry picked from commit 53bdef48cc8a14c23afc2223c9a8826a0f587ac7)
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/transaction_participant.h | 9 |
3 files changed, 7 insertions, 16 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 2711ee95da9..69a144d89c6 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -276,7 +276,7 @@ public: uassert(ErrorCodes::OperationNotSupportedInTransaction, "The 'readOnce' option is not supported within a transaction.", - !txnParticipant || !txnParticipant.inActiveOrKilledMultiDocumentTransaction() || + !txnParticipant || !txnParticipant.inMultiDocumentTransaction() || !qr->isReadOnce()); uassert(ErrorCodes::InvalidOptions, @@ -287,7 +287,7 @@ public: uassert( ErrorCodes::OperationNotSupportedInTransaction, "The '$_internalReadAtClusterTime' option is not supported within a transaction.", - !txnParticipant || !txnParticipant.inActiveOrKilledMultiDocumentTransaction() || + !txnParticipant || !txnParticipant.inMultiDocumentTransaction() || !qr->getReadAtClusterTime()); uassert(ErrorCodes::InvalidOptions, diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 685672de251..dedb2683898 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -246,7 +246,7 @@ bool handleError(OperationContext* opCtx, } auto txnParticipant = TransactionParticipant::get(opCtx); - if (txnParticipant && txnParticipant.inActiveOrKilledMultiDocumentTransaction()) { + if (txnParticipant && txnParticipant.inMultiDocumentTransaction()) { if (isTransientTransactionError( ex.code(), false /* hasWriteConcernError */, false /* isCommitTransaction */)) { // Tell the client to try the whole txn again, by returning ok: 0 with errorLabels. @@ -400,7 +400,7 @@ bool insertBatchAndHandleErrors(OperationContext* opCtx, try { acquireCollection(); auto txnParticipant = TransactionParticipant::get(opCtx); - auto inTxn = txnParticipant && txnParticipant.inActiveOrKilledMultiDocumentTransaction(); + auto inTxn = txnParticipant && txnParticipant.inMultiDocumentTransaction(); if (!collection->getCollection()->isCapped() && !inTxn && batch.size() > 1) { // First try doing it all together. If all goes well, this is all we need to do. // See Collection::_insertDocuments for why we do all capped inserts one-at-a-time. @@ -491,7 +491,7 @@ WriteResult performInserts(OperationContext* opCtx, // transaction. auto txnParticipant = TransactionParticipant::get(opCtx); invariant(!opCtx->lockState()->inAWriteUnitOfWork() || - (txnParticipant && txnParticipant.inActiveOrKilledMultiDocumentTransaction())); + (txnParticipant && txnParticipant.inMultiDocumentTransaction())); auto& curOp = *CurOp::get(opCtx); ON_BLOCK_EXIT([&] { // This is the only part of finishCurOp we need to do for inserts because they reuse the @@ -758,7 +758,7 @@ WriteResult performUpdates(OperationContext* opCtx, const write_ops::Update& who // transaction. auto txnParticipant = TransactionParticipant::get(opCtx); invariant(!opCtx->lockState()->inAWriteUnitOfWork() || - (txnParticipant && txnParticipant.inActiveOrKilledMultiDocumentTransaction())); + (txnParticipant && txnParticipant.inMultiDocumentTransaction())); uassertStatusOK(userAllowedWriteNS(wholeOp.getNamespace())); DisableDocumentValidationIfTrue docValidationDisabler( @@ -915,7 +915,7 @@ WriteResult performDeletes(OperationContext* opCtx, const write_ops::Delete& who // transaction. auto txnParticipant = TransactionParticipant::get(opCtx); invariant(!opCtx->lockState()->inAWriteUnitOfWork() || - (txnParticipant && txnParticipant.inActiveOrKilledMultiDocumentTransaction())); + (txnParticipant && txnParticipant.inMultiDocumentTransaction())); uassertStatusOK(userAllowedWriteNS(wholeOp.getNamespace())); DisableDocumentValidationIfTrue docValidationDisabler( diff --git a/src/mongo/db/transaction_participant.h b/src/mongo/db/transaction_participant.h index f69579a4069..cd210a47f03 100644 --- a/src/mongo/db/transaction_participant.h +++ b/src/mongo/db/transaction_participant.h @@ -310,15 +310,6 @@ public: } /** - * Returns true if we are in an active multi-document transaction or if the transaction has - * been aborted. This is used to cover the case where a transaction has been aborted, but - * the OperationContext state has not been cleared yet. - */ - bool inActiveOrKilledMultiDocumentTransaction() const { - return o().txnState.inMultiDocumentTransaction() || o().txnState.isAborted(); - } - - /** * If this session is holding stashed locks in txnResourceStash, reports the current state * of the session using the provided builder. */ |