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

CTRL-C in mongo shell does not terminate long running ops if connected to mongos

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.10
    • Component/s: Shell
    • Query Execution
    • ALL
    • Hide
      1. Create a sharded cluster (e.g. mlaunch init --sharded 1 --single --port 47017)
      2. Connect to the mongos using the mongo shell: mongo --port 47017
      3. Start a long-running operation:
        use test
        db.foo.remove({})
        db.foo.insert({})
        db.foo.find({$where: "for(var i=0;i<100000;i++) sleep(1000)"})
        
      4. Launch a second mongo shell mongo --port 47017 and execute db.currentOp(). Notice the long-running operation started in the previous step.
      5. In the first shell, press CTRL-C. Notice that you are not prompted to terminate the operation.
      6. In the second shell, run db.currentOp(). Notice that the long-running operation is still executing.

      If you repeat the above steps connected to the mongod directly instead, you are prompted to terminate the long-running command as expected.

      Show
      Create a sharded cluster (e.g. mlaunch init --sharded 1 --single --port 47017 ) Connect to the mongos using the mongo shell: mongo --port 47017 Start a long-running operation: use test db.foo.remove({}) db.foo.insert({}) db.foo.find({$where: " for ( var i=0;i<100000;i++) sleep(1000)" }) Launch a second mongo shell mongo --port 47017 and execute db.currentOp() . Notice the long-running operation started in the previous step. In the first shell, press CTRL-C. Notice that you are not prompted to terminate the operation. In the second shell, run db.currentOp() . Notice that the long-running operation is still executing. If you repeat the above steps connected to the mongod directly instead, you are prompted to terminate the long-running command as expected.
    • Query 2018-03-26

      killOperationsOnAllConnections is called in response to CTRL-C in the mongo shell. It finds long-running operations started by this shell and provides the user the option to terminate them. This is accomplished with the currentOp and killOp commands.

      For each connection, the shell calls currentOp and examines client or client_s to determine if that command was started by the current shell. When a command is run against a mongod, client contains the IP:PORT of the mongo shell. These commands prompt for termination. If however the command is routed through a mongos, client_s contains the IP:PORT of the mongos, not the mongo shell. These commands do not prompt for termination and are left running on the mongod.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            james.kovacs@mongodb.com James Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: