Navigation
This version of the documentation is archived and no longer supported.

abortTransaction

On this page

Definition

abortTransaction

New in version 4.0.

Terminates the multi-document transaction and rolls back any data changes made by the operations within the transaction. That is, the transaction ends without saving any of the changes made by the operations in the transaction.

Tip

In the mongo Shell, this command can also be run through the Session.abortTransaction helper method.

Helper methods are convenient for mongo users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

To run the abortTransaction, the command must be run against the admin database and run within a Session.

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 the transaction are discarded without ever becoming visible and the transaction ends.

Security

If running with auditing, operations in an aborted transaction are still audited.