abortTransaction
Definition
New in version 4.0.
Terminates the multi-document transaction and rolls back any data changes made by theoperations within the transaction. That is, the transaction endswithout saving any of the changes made by the operations in thetransaction.
To run the abortTransaction
, the command must be runagainst the admin
database and run within aSession
. Rather than run the abortTransaction
command directly, most users should use the driver method or themongo
shell Session.abortTransaction()
helper.
The command has the following syntax:
- {
- abortTransaction: 1,
- txnNumber: <long>,
- writeConcern: <document>,
- autocommit: false
- }
Behavior
Atomicity
When a transaction aborts, all data changes made by the writes in thetransaction are discarded without ever becoming visible and thetransaction ends.
Security
If running with auditing, operations in anaborted transaction are still audited.