On this page本页内容
abortTransaction
New in version 4.0.在版本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()
. abortTransaction
,必须对admin
数据库运行该命令,并在Session()
中运行。Rather than run the 大多数用户应该使用驱动程序方法或abortTransaction
command directly, most users should use the driver method or the mongosh
Session.abortTransaction()
helper.mongosh
Session.abortTransaction()
助手,而不是直接运行abortTransaction
命令。
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.如果使用审核运行,则中止事务中的操作仍将被审核。