Docs Menu

Docs HomeMongoDB Manual


On this page

  • Definition
  • Syntax
  • Behavior

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.

To run the abortTransaction, the command must be run against the admin database and run within a Session(). Rather than run the abortTransaction command directly, most users should use the driver method or the mongoshSession.abortTransaction() helper.

The command has the following syntax:

abortTransaction: 1,
txnNumber: <long>,
writeConcern: <document>,
autocommit: false,
comment: <any>

When a transaction aborts, all data changes made by the writes in the transaction are discarded without ever becoming visible and the transaction ends.

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

←  Sessions CommandscommitTransaction →
Give Feedback
© 2022 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.