From 2ff54098b19ebc2b4bbf5516de6e6befb46f9fe7 Mon Sep 17 00:00:00 2001 From: Suganthi Mani Date: Wed, 24 Jul 2019 14:11:58 -0400 Subject: SERVER-41881 Unstashing the transaction lock resources should ignore the saved value of maxLockTimeout and explicitly set the maxLockTimeout based on node's state. SERVER-41883 Replication state transition reacquires locks and tickets of a prepared transaction with no lock timeout. SERVER-41556 Handles failure to reacquire locks and ticket when unstashing transactions. --- src/mongo/db/transaction_participant.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/mongo/db/transaction_participant.h') diff --git a/src/mongo/db/transaction_participant.h b/src/mongo/db/transaction_participant.h index d6947e36b6b..e907a61d077 100644 --- a/src/mongo/db/transaction_participant.h +++ b/src/mongo/db/transaction_participant.h @@ -202,9 +202,9 @@ public: TxnResources& operator=(TxnResources&&) = default; /** - * Returns a const pointer to the stashed lock state, or nullptr if no stashed locks exist. + * Returns a pointer to the stashed lock state, or nullptr if no stashed locks exist. */ - const Locker* locker() const { + Locker* locker() const { return _locker.get(); } @@ -357,6 +357,9 @@ public: */ class Participant : public Observer { public: + // Indicates whether the future lock requests should have timeouts. + enum class MaxLockTimeout { kNotAllowed, kAllowed }; + explicit Participant(OperationContext* opCtx); explicit Participant(const SessionToKill& session); @@ -770,9 +773,22 @@ public: // invalidating a transaction, or starting a new transaction. void _resetTransactionState(WithLock wl, TransactionState::StateFlag state); - // Releases the resources held in *o().txnResources to the operation context. - // o().txnResources must be engaged prior to calling this. - void _releaseTransactionResourcesToOpCtx(OperationContext* opCtx); + /* Releases the resources held in *o().txnResources to the operation context. + * o().txnResources must be engaged prior to calling this. + * + * maxLockTimeout will determine whether future lock requests should have lock timeouts. + * - MaxLockTimeout::kNotAllowed will clear the lock timeout. + * - MaxLockTimeout::kAllowed will set the timeout as + * MaxTransactionLockRequestTimeoutMillis. + * + * ------------------------------------------------------------------ + * | | PRIMARY | SECONDARY | STATE TRANSITION | + * |----------------|------------|---------------|------------------| + * |maxLockTimeout | kAllowed | kNotAllowed | kNotAllowed | + * ------------------------------------------------------------------ + */ + void _releaseTransactionResourcesToOpCtx(OperationContext* opCtx, + MaxLockTimeout maxLockTimeout); TransactionParticipant::PrivateState& p() { return _tp->_p; -- cgit v1.2.1