对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

abortTransaction(数据库命令)

abortTransaction

终止多文档事务并回滚事务内操作所做的任何数据更改。也就是说,事务结束时不会保存事务中操作所做的任何更改。

提示

In mongosh, this command can also be run through the Session.abortTransaction() helper method.

Helper methods are convenient for mongosh 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().

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

注意

所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令

该命令具有以下语法:

db.adminCommand(
{
abortTransaction: 1,
txnNumber: <long>,
writeConcern: <document>,
autocommit: false,
comment: <any>
}
)

当事务中止时,事务中通过写入进行的所有数据更改都会丢弃且变得不可见,同时事务结束。

如果以审核方式运行,中止的事务中的操作仍会被审核。

给本页内容打分