FEATURE DESCRIPTION
This feature provides the following functionality:
- Allows operators to list and kill queries running in a sharded cluster directly on a mongos node.
- When a sharded query is killed on one shard, this causes the query to be terminated promptly in all other shards in the cluster.
VERSIONS
This feature is available in the 3.7.4 and newer development versions, and in the 4.0 and newer MongoDB production releases.
RATIONALE
Before this feature, killing a query which is active across multiple targeted shards required operators to run killOp manually against each of the involved shards. Killing a query on one shard did not always terminate the operation in a timely manner across the entire cluster.
In addition, killing a sharded query on a mongos node was not possible.
OPERATION
Sharded queries running on a mongos can be listed using the localOps flag to the $currentOp aggregation metadata source:
mongos> use admin; mongos> db.aggregate([{$currentOp: {localOps: true}}]);
The reported operation IDs identify operations running on the mongos node. A mongos-local operation ID can be used as an argument to the killOp command in order to terminate the queries that mongos issued to the targeted shards on behalf of the client. For instance, to kill a particular sharded operation matching <filter> use:
mongos> use admin; mongos> let opToKill = db.aggregate([{$currentOp: {localOps: true}}, {$match: <filter>}]).toArray()[0]; mongos> let opid = opToKill.opid; mongos> db.killOp(opid)
Original Description
When trying to kill a query through mongos, It requires killing the query manually on every single shard.
Running queries without specifying a shard key or worse, without an index can be unacceptable in some scenarios and is an innocent mistake (consider killing a sharded query on a cluster of 100 shards).
- depends on
-
SERVER-28090 Add ability to interrupt operations using pinned cursors on mongos
- Closed
- is related to
-
SERVER-18094 currentOp on a mongoS should also show current mongoS operations
- Closed
-
SERVER-32307 Make AsyncResultsMerger kill sequence issue killCursors without waiting for outstanding batches
- Closed
-
SERVER-33462 Allow killop on a mongos op id
- Closed
- related to
-
SERVER-25497 Fix sharded query path to handle shutdown of the mongos process
- Closed
-
SERVER-4984 make it possible to interrupt operations in mongos
- Closed
-
SERVER-17696 Terminate sharded queries immediately after a failure
- Closed