AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

abortTransaction (データベースコマンド)

abortTransaction

マルチドキュメントトランザクションを終了し、トランザクション内の操作によって行われたデータ変更をロールバックします。 つまり、トランザクション内の操作によって行われた変更を保存せずにトランザクションは終了します。

Tip

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: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

このコマンドの構文は、次のとおりです。

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

トランザクションが中止されると、トランザクション内の書込み (write) によって行われたすべてのデータ変更は、参照可能にならずに破棄され、トランザクションは終了します。

監査付きで実行している場合、中止されたトランザクションの操作は引き続き監査されます。

このページを評価