summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction_participant.h
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-07-24 14:11:58 -0400
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-07-24 23:57:48 -0400
commit2ff54098b19ebc2b4bbf5516de6e6befb46f9fe7 (patch)
tree200a13c7e8f0cb5ea5bd6f35093689c150220bc4 /src/mongo/db/transaction_participant.h
parentf5f62f877b62523205d02f810f351b06cf1e58c4 (diff)
downloadmongo-2ff54098b19ebc2b4bbf5516de6e6befb46f9fe7.tar.gz
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.
Diffstat (limited to 'src/mongo/db/transaction_participant.h')
-rw-r--r--src/mongo/db/transaction_participant.h26
1 files changed, 21 insertions, 5 deletions
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;