abortTransaction

Definition

  • abortTransaction

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 abortTransactioncommand directly, most users should use the driver method or themongo shell Session.abortTransaction()helper.

The command has the following syntax:

  1. {
  2. abortTransaction: 1,
  3. txnNumber: <long>,
  4. writeConcern: <document>,
  5. autocommit: false
  6. }

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.