Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-430

Test that killCursors really succeeds

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Implementing
    • Major - P3
    • Resolution: Unresolved
    • None

    Description

      In SERVER-32169 we noticed that it's easy to miss bugs in drivers' killCursors implementations. The killCursors command can fail but still report "ok: 1", listing the cursor ids it failed to kill in the "cursorsAlive" array:

      > db.runCommand({killCursors: "collection", cursors: [NumberLong(0)]})
      {
        ok: 1,
        cursorsNotFound: [NumberLong(0)],
        cursorsKilled: [],
        cursorsAlive: []
      }
      

      If your driver already includes tests that prove it really can kill a cursor, then you don't need to do anything. For example, PyMongo can't always kill a cursor with MongoDB 3.7.x due to SERVER-32169, and this was discovered because three of PyMongo's tests fail with MongoDB 3.7.x. If you driver has tests which fail due to SERVER-32169 then you may be able to validate this ticket already. Otherwise, here's a suggested test.

      Write a test in each driver that checks we really kill a cursor:

      • insert 1000 documents into a collection
      • do a "find" on the collection and iterate the cursor past the first document
      • store the cursor id in a variable
      • assert the cursor id is nonzero
      • kill the cursor (explicitly, or by letting it go out of scope, depending on the driver)
      • assert that the driver receives a server reply to "killCursors" with "ok: 1", an empty "cursorsNotFound" array, an empty "cursorsAlive" array, an empty "cursorsUnknown" array, and a "cursorsKilled" array with one element equal to the cursor id

      Drivers can use Command Monitoring, if they've implemented it, to check the server reply.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jesse@mongodb.com A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: