Skip to content

Commit 75afc39

Browse files
committed
DOCS-11716: maxTransactionLockRequestTimeoutMillis
1 parent 41df190 commit 75afc39

File tree

4 files changed

+123
-22
lines changed

4 files changed

+123
-22
lines changed

source/core/transactions-production-consideration.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,18 @@ To prevent storage cache pressure from immobilizing the system:
4444

4545
The :parameter:`transactionLifetimeLimitSeconds` also ensures that
4646
expired transactions are aborted periodically.
47+
48+
Lock Request Timeout
49+
--------------------
50+
51+
By default, transactions waits ``5`` milliseconds to acquire locks
52+
required by the operations in the transaction. If the transaction
53+
cannot acquire its required locks within the ``5`` milliseconds, the
54+
transaction aborts.
55+
56+
Increasing :parameter:`maxTransactionLockRequestTimeoutMillis` allows
57+
operations in the transactions to wait the specified time to acquire
58+
the required locks. This can help obviate transaction abortion on
59+
momentary concurrent lock acquisitions, like fast-running metadata
60+
operations. However, this could possibly delay the abort of deadlocked
61+
transaction operations.

source/core/transactions.txt

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ engine, you must set :rsconf:`writeConcernMajorityJournalDefault` to
7373

7474
.. _transactions-operations:
7575

76-
Transactions and CRUD Operations
77-
--------------------------------
76+
Transactions and Operations
77+
---------------------------
7878

7979
For multi-document transactions:
8080

@@ -124,6 +124,22 @@ Transactions and Security
124124
- If running with :doc:`auditing </core/auditing>`, operations in an
125125
aborted transaction are still audited.
126126

127+
Transactions and Locks
128+
----------------------
129+
130+
By default, transactions waits ``5`` milliseconds to acquire locks
131+
required by the operations in the transaction. If the transaction
132+
cannot acquire its required locks within the ``5`` milliseconds, the
133+
transaction aborts.
134+
135+
You can use the :parameter:`maxTransactionLockRequestTimeoutMillis`
136+
parameter to adjust how long transactions wait to acquire locks.
137+
138+
You can also use operation-specific timeout by setting
139+
:parameter:`maxTransactionLockRequestTimeoutMillis` to ``-1``.
140+
141+
Transactions release all locks upon abort.
142+
127143
Transactions and Sessions
128144
-------------------------
129145

@@ -165,22 +181,6 @@ transactions:
165181

166182
- :method:`Session.abortTransaction()`
167183

168-
Atomicity
169-
---------
170-
171-
Multi-document transactions are atomic:
172-
173-
- When a transaction commits, all data changes made in the transaction
174-
are saved and visible outside the transaction. Until a transaction
175-
commits, the data changes made in the transaction are not visible
176-
outside the transaction.
177-
178-
- When a transaction aborts, all data changes made in the transaction
179-
are discarded without ever becoming visible. For example, if any
180-
operation in the transaction fails, the transaction aborts and all
181-
data changes made in the transaction are discarded without ever
182-
becoming visible.
183-
184184
.. _transactions-retry:
185185

186186
Transactions and Retryable Writes
@@ -354,6 +354,22 @@ and retrying the commit, the full code example is:
354354
session.endSession();
355355
}
356356

357+
Atomicity
358+
---------
359+
360+
Multi-document transactions are atomic:
361+
362+
- When a transaction commits, all data changes made in the transaction
363+
are saved and visible outside the transaction. Until a transaction
364+
commits, the data changes made in the transaction are not visible
365+
outside the transaction.
366+
367+
- When a transaction aborts, all data changes made in the transaction
368+
are discarded without ever becoming visible. For example, if any
369+
operation in the transaction fails, the transaction aborts and all
370+
data changes made in the transaction are discarded without ever
371+
becoming visible.
372+
357373
Read Preference
358374
---------------
359375

source/reference/parameters.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,59 @@ Logical Session Parameters
12331233

12341234
.. seealso:: :parameter:`localLogicalSessionTimeoutMinutes`
12351235

1236+
.. parameter:: maxTransactionLockRequestTimeoutMillis
1237+
1238+
.. versionadded:: 4.0
1239+
1240+
|mongod-only|
1241+
1242+
*Type*: integer
1243+
1244+
*Default*: 5
1245+
1246+
The amount of time in milliseconds that :doc:`multi-document
1247+
transactions </core/transactions>` should wait to aquire locks
1248+
required by the operations in the transaction.
1249+
1250+
If the transaction cannot aquire the locks after waiting
1251+
:parameter:`maxTransactionLockRequestTimeoutMillis`, the transaction
1252+
aborts.
1253+
1254+
By default, :doc:`multi-document transactions </core/transactions>`
1255+
wait ``5`` milliseconds. That is, if the transaction cannot acquire
1256+
the locks within ``5`` milliseconds, the transaction aborts. If an
1257+
operation provides a greater timeout in a lock request,
1258+
:parameter:`maxTransactionLockRequestTimeoutMillis` overrides the
1259+
operation-specific timeout.
1260+
1261+
You can set :parameter:`maxTransactionLockRequestTimeoutMillis` to:
1262+
1263+
- ``0`` such that if the transaction cannot acquire the required
1264+
locks immediately, the transaction aborts.
1265+
1266+
- A number greater than ``0`` to wait the specified time to acquire
1267+
the required locks. This can help obviate transaction abortion on
1268+
momentary concurrent lock acquisitions, like fast-running metadata
1269+
operations. However, this could possibly delay the abort of
1270+
deadlocked transaction operations.
1271+
1272+
- ``-1`` to use the operation specific timeout.
1273+
1274+
The following sets the
1275+
:parameter:`maxTransactionLockRequestTimeoutMillis` to ``20``
1276+
milliseconds:
1277+
1278+
.. code-block:: javascript
1279+
1280+
db.adminCommand( { setParameter: 1, maxTransactionLockRequestTimeoutMillis: 20 } )
1281+
1282+
You can also set this parameter during start-up:
1283+
1284+
.. code-block:: sh
1285+
1286+
mongod --setParameter maxTransactionLockRequestTimeoutMillis=20
1287+
1288+
12361289
Replication Parameters
12371290
~~~~~~~~~~~~~~~~~~~~~~
12381291

source/release-notes/4.0.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ Commands
9797
Use the corresponding driver method or :binary:`~bin.mongo` shell
9898
helper :method:`Session.commitTransaction()` instead.
9999

100+
Locks
101+
~~~~~
102+
103+
By default, :doc:`multi-document transactions </core/transactions>`
104+
wait ``5`` milliseconds to acquire locks required by the operations in
105+
the transaction. If the transaction cannot acquire its required locks
106+
with the ``5`` milliseconds, the transaction aborts.
107+
108+
You can use the :parameter:`maxTransactionLockRequestTimeoutMillis`
109+
parameter to adjust how long transactions wait to acquire locks.
110+
111+
Transactions release all locks upon abort or commit.
112+
100113
``$currentOp``
101114
~~~~~~~~~~~~~~
102115

@@ -108,10 +121,14 @@ which are holding locks as part of a transaction.
108121
Parameters
109122
~~~~~~~~~~
110123

111-
:parameter:`transactionLifetimeLimitSeconds` to specify the lifetime
112-
for a :doc:`multi-document transaction </core/transactions>` after
113-
which the transaction is considered expired and will be aborted when
114-
the periodic cleanup process next runs.
124+
- :parameter:`transactionLifetimeLimitSeconds` to specify the lifetime
125+
for a :doc:`multi-document transaction </core/transactions>` after
126+
which the transaction is considered expired and will be aborted when
127+
the periodic cleanup process next runs.
128+
129+
- :parameter:`maxTransactionLockRequestTimeoutMillis` to specify how
130+
long :doc:`multi-document transactions </core/transactions>` should
131+
wait to aquire locks required by the operations in the transaction.
115132

116133
Aggregation
117134
-----------

0 commit comments

Comments
 (0)