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

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

killOp

Terminates an operation as specified by the operation ID. mongosh provides the db.killOp() helper. To find operations and their corresponding IDs, see $currentOp or db.currentOp().

killOpコマンドはadminデータベースに対して実行する必要があります。

killOp を実行するには、 db.runCommand( { <command> } )メソッドを使用します。

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

重要

このコマンドは、すべてのMongoDB Atlasクラスターでのサポートが制限されています。詳細については、サポートされていないコマンド を参照してください。

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

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

コマンドの形式は次のとおりです。

db.adminCommand(
{
killOp: 1,
op: <opid>,
comment: <any>
}
)
Parameter
タイプ
説明

op

数値

操作 ID。

comment

any

任意。このコマンドに添付するユーザー指定のコメント。設定すると、このコメントは以下の場所にこのコマンドの記録と合わせて表示されます。

コメントには、有効な BSON 型(string, integer, object, array など)を使用できます。

警告

Terminate running operations with extreme caution. Only use killOp to terminate operations initiated by clients and do not terminate internal database operations.

Do not use killOp to terminate an in-progress index builds in replica sets or sharded clusters. Use dropIndexes on the primary to drop the index. See Stop In-Progress Index Builds.

authorization で実行されているシステムでは、ユーザー自身のものでない操作を強制終了するには、ユーザーに killop 特権アクションを含むアクセス権が必要です。

mongod インスタンスでは、ユーザーは killop 特権アクションがなくても自分の操作を強制終了できます。

The killOp command can be run on a mongos and can kill queries (i.e. read operations) that span shards in a cluster. The killOp command from the mongos does not propagate to the shards when the operation to be killed is a write operation.

mongos でアクティブなシャーディング操作を一覧表示する方法の詳細については、$currentOp の localOps パラメーターを参照してください。

シャーディングされたクラスターでの操作の強制終了の詳細と例については、以下を参照してください。

The following example uses killOp to target the running operation with opid 3478.

db.adminCommand( { "killOp": 1, "op": 3478 } )

この操作では、次の結果を返します。

{ "info" : "attempting to kill op", "ok" : 1 }

killOp reports success if it succeeded in marking the specified operation for termination. Operations may not actually be terminated until they reach an appropriate interruption point. Use $currentOp or db.currentOp() to confirm the target operation was terminated.