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

Make killCursors work against pinned cursors on mongos when auth is enabled

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 3.7.2
    • None
    • Querying
    • None
    • Fully Compatible
    • Query 2018-02-12

    Description

      If you try to "killCursors" a pinned cursor on a mongos with auth enabled, you will get a CursorInUse error.

      The reason is that during the auth checking codepath, we try to check out the cursor (also here) which can return a CursorInUse error. The sharded kill project is supposed to let killCursor kill the cursor regardless of whether it's in use, so I think we should change this behavior.

      Here's a way to reproduce the problem:

      var coll = db.c;
      coll.drop();
       
      for (var i = 0; i < 10; i++) {
          assert.writeOK(coll.insert({_id: i}));
      }
       
       
      var failpointName = "keepCursorPinnedDuringGetMore";
      var cleanup;
      try {
          assert.commandWorked(
              db.adminCommand({configureFailPoint: failpointName, mode: "alwaysOn"}));
       
          var cmdRes = db.runCommand({find: coll.getName(), batchSize: 2});
          assert.commandWorked(cmdRes);
          cursorId = cmdRes.cursor.id;
          assert.neq(cursorId, NumberLong(0));
       
          // Pin the cursor during a getMore.
          var code = 'db.runCommand({getMore: ' + cursorId.toString() + ', collection: "' +
              coll.getName() + '"});';
          cleanup = startParallelShell(code);
       
          // Sleep for a long time, so we can assume that the cursor will be pinned.
          sleep(5000);
       
          cmdRes = db.runCommand({killCursors: coll.getName(), cursors: [cursorId]});
       
          printjson(cmdRes);
      }
      finally {
          cleanup();
          assert.commandWorked(db.adminCommand({configureFailPoint: failpointName, mode: "off"}));
      }
      

      We should change the auth check to work so that checking out the cursor isn't necessary.

      Attachments

        Activity

          People

            ian.boros@mongodb.com Ian Boros
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: