summaryrefslogtreecommitdiff
path: root/src/mongo/db/session.h
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2018-07-19 22:04:20 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2018-07-30 17:43:59 -0400
commit6a8543890960053d1d59c62a43a8804a23fe8f06 (patch)
tree785e58849175a53e822cd70bced64d71f2fe521b /src/mongo/db/session.h
parente8379141cd2fd3f841c87a2817cc04c4830ed72e (diff)
downloadmongo-6a8543890960053d1d59c62a43a8804a23fe8f06.tar.gz
SERVER-35809 Refactor transaction abort.
Diffstat (limited to 'src/mongo/db/session.h')
-rw-r--r--src/mongo/db/session.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/db/session.h b/src/mongo/db/session.h
index f7ff349c45b..9dada17bece 100644
--- a/src/mongo/db/session.h
+++ b/src/mongo/db/session.h
@@ -493,6 +493,12 @@ private:
kAborted = 1 << 6
};
+ using StateSet = int;
+
+ bool isInSet(WithLock, StateSet stateSet) const {
+ return _state & stateSet;
+ }
+
/**
* Transitions the session from the current state to the new state. If transition validation
* is not relaxed, invariants if the transition is illegal.
@@ -555,10 +561,18 @@ private:
return (s << txnState.toString());
}
+ // Abort the transaction if it's in one of the expected states and clean up the transaction
+ // states associated with the opCtx.
+ void _abortActiveTransaction(OperationContext* opCtx,
+ TransactionState::StateSet expectedStates);
+
void _abortArbitraryTransaction(WithLock);
- // Releases stashed transaction resources to abort the transaction.
- void _abortTransaction(WithLock);
+ // Releases stashed transaction resources to abort the transaction on the session.
+ void _abortTransactionOnSession(WithLock);
+
+ // Clean up the transaction resources unstashed on operation context.
+ void _cleanUpTxnResourceOnOpCtx(OperationContext* opCtx);
// Committing a transaction first changes its state to "Committing*" and writes to the oplog,
// then it changes the state to "Committed".