251: NoSuchTransaction (error code 251)
MongoDBWhat does it mean?
The referenced multi-document transaction was not found. The transaction has already ended, timed out, or an invalid transaction number was used.
Why does it happen?
The transaction exceeded transactionLifetimeLimitSeconds and was aborted automatically, the session ended, a wrong/stale txnNumber, or continuing a transaction that was already aborted after an error.
How to fix it
Restart the transaction from the beginning (with a new session). Keep transactions short; design them to finish within the default lifetime (60 s). For errors labeled TransientTransactionError, retry the whole transaction safely. If long transactions are required, review the transactionLifetimeLimitSeconds setting.