summaryrefslogtreecommitdiff
path: root/src/mongo/db/session.cpp
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@gmail.com>2018-07-31 16:36:09 -0400
committerSamy Lanka <samy.lanka@gmail.com>2018-08-01 16:19:57 -0400
commit124b9963e852ca8cb845c893922b63e26eaed3a5 (patch)
tree23fb0d7c8ad2c7ff359a5feb6a2a561557ce0986 /src/mongo/db/session.cpp
parent30298ed63aadae19bd5494dd0e1f33e329389806 (diff)
downloadmongo-124b9963e852ca8cb845c893922b63e26eaed3a5.tar.gz
SERVER-35864 Ensure the active transaction on the session has not already been commit or aborted when receiving a prepareTransaction command
Diffstat (limited to 'src/mongo/db/session.cpp')
-rw-r--r--src/mongo/db/session.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 382df5e4854..e208d22f647 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -856,6 +856,10 @@ Timestamp Session::prepareTransaction(OperationContext* opCtx) {
// session kill and migration, which do not check out the session.
_checkIsActiveTransaction(lk, *opCtx->getTxnNumber(), true);
+ uassert(ErrorCodes::TransactionCommitted,
+ str::stream() << "Transaction " << *opCtx->getTxnNumber() << " has been committed.",
+ !_txnState.isCommitted(lk));
+
_txnState.transitionTo(lk, TransactionState::kPrepared);
// We need to unlock the session to run the opObserver onTransactionPrepare, which calls back