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

"Cursor not found" does not "kill" instances of cursor.Cursor

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7
    • Affects Version/s: None
    • Component/s: None
    • None

      When the CursorNotFound bit is set on a getMore result PyMongo raises OperationFailure with an appropriate explanation. However, cursor.Cursor doesn't catch the exception and set its internal __killed flag to True. This means that 1) we pointlessly send OP_KILL_CURSORS to the server when the Cursor instance is destroyed and 2) Cursor.alive returns True when it should be returning False. A proposed fix:

      1. Raise a new exception for CursorNotFound, inheriting from OperationFailure so we don't break existing code.
      2. Catch the exception in cursor.Cursor and command_cursor.CommandCursor, setting __killed to True.
      3. If the cursor is not tailable re-raise the exception. This makes it easier to deal with capped collection roll over when iterating a tailable cursor.

      http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#op-reply

      Issue raised on mongodb-user: https://groups.google.com/forum/#!topic/mongodb-user/fX5MvfYjAXc

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: