定義
abortTransactionマルチドキュメントトランザクションを終了し、トランザクション内の操作によって行われたデータ変更をロールバックします。 つまり、トランザクション内の操作によって行われた変更を保存せずにトランザクションは終了します。
Tip
In
mongosh, this command can also be run through theSession.abortTransaction()helper method.Helper methods are convenient for
mongoshusers, 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 theadmindatabase and run within aSession().
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
- 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) によって行われたすべてのデータ変更は、参照可能にならずに破棄され、トランザクションは終了します。
セキュリティ
監査付きで実行している場合、中止されたトランザクションの操作は引き続き監査されます。