Limits and long transactions
How long a transaction can last and how much it can take.
Fit your transactions to their time and memory limits, or raise the time limit if your case asks for it.
Requirements
- A user allowed to run
setParameterif you are going to change the limit.
Duration
A transaction aborts once it goes past transactionLifetimeLimitSeconds, 60 seconds by default. To change it:
JavaScript
db.adminCommand({ setParameter: 1, transactionLifetimeLimitSeconds: 120 });Size
The state of the transaction must fit in its coordinator's memory. A transaction that writes too many documents fails
with TransactionTooLarge (257).
Check
JavaScript
db.adminCommand({ getParameter: 1, transactionLifetimeLimitSeconds: 1 });getParameter answers with the value of transactionLifetimeLimitSeconds in force on the node your session uses, so
you can see the lifetime limit that a transaction started from that session will run into.
Common problems
- A bulk load inside a transaction runs into both limits. Do the load in batches outside a transaction.