Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2799

killCursors must use the namespace returned the initial command response when closing cursors

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.12, 4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      In PYTHON-2182 we updated PyMongo's Cursor class to use the namespace returned by the initial find command for running all subsequent getMore operations. However, we did not change how we close cursors server-side and as a result killCursors still uses the database.collection convention to specify the namespace in which to close cursors. This should be updated to follow the same logic as find/getMore.

      For example, when running a find against Atlas Data Lake on a the test.driverdata collection, we get the following command response:

      {'ok': 1, 'cursor': {'firstBatch': [{'a': 1, 'b': 2, 'c': 3}, {'a': 2, 'b': 3, 'c': 4}], 'id': 5, 'ns': 'cursors.ip-10-122-14-95-0a89e0bd-da01-4e9b-ae4e-91b40cd97495'}}
      

      Upon closing the cursor, the outgoing killCursors command looks like this:

      SON([('killCursors', 'driverdata'), ('cursors', [5]), ('lsid', {'id': Binary(b'\x9by\x86U\xda\xaeA\x1f\x87\xfd\xc3\xcb \xa4\xfb\xdd', 4)}), ('$db', 'test'), ('$readPreference', {'mode': 'primary'})])
      

      Consequently, the server is unable to find and kill the cursor as evidenced by the killCursors command response:

      {'ok': 1, 'cursorsKilled': [], 'cursorsNotFound': [5], 'cursorsAlive': [], 'cursorsUnknown': []}
      

            Assignee:
            prashant.mital Prashant Mital (Inactive)
            Reporter:
            prashant.mital Prashant Mital (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: