Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6496

provide a way to kill a sharded query on all shards

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0-rc0
    • Affects Version/s: None
    • Component/s: Querying, Sharding
    • None
    • Query
    • Fully Compatible

      Issue Status as of April 4, 2018

      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).

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            alonho Alon Horev
            Votes:
            17 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated:
              Resolved: