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

Server closes cursors that are still in use during session cache refresh

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 3.6.7
    • Component/s: Sharding
    • None
    • ALL
    • Sharding 2018-09-10

      In PYTHON-1626, multiple users report that the server is closing cursors that are still in use resulting in pymongo.errors.CursorNotFound: cursor id 56626714158 not found errors when iterating a cursor. This appears to be the same issue as SERVER-34810 but upgrading to 3.6.6 and 3.6.7 did not resolve the issue.

      I can reproduce this issue simply by iterating a cursor on a secondary (3 member replica set with auth enabled running 3.6.7) and waiting 30 seconds between each getMore command. The cursor is usually closed by the server within a few (<5) minutes.

      I've attached a repro script that prints the commands that pymongo is running: python-1626.py

      The script fails after a few minutes (presumably when the session cache is synced to the sessions collection):

      Command getMore with request id 1137623865 failed in 1098 microseconds, failure:
      {u'code': 43, u'ok': 0.0, u'$clusterTime': {u'clusterTime': Timestamp(1534962428, 1), u'signature': {u'keyId': 6592612058754187265L, u'hash': Binary('\xa5mr\xe9\xe1)\x95\xae"[\x05\xa7\xe6\x93\xa2\x98\xb9M\x88c', 0)}}, u'codeName': u'CursorNotFound', u'operationTime': Timestamp(1534962428, 1), u'errmsg': u'cursor id 56626714158 not found'}
      
      Traceback (most recent call last):
        File "python-1626.py", line 57, in <module>
          for doc in coll.find(batch_size=10, limit=1000):
        File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 1189, in next
          if len(self.__data) or self._refresh():
        File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 1126, in _refresh
          self.__send_message(g)
        File "/Users/shane/git/mongo-python-driver/pymongo/cursor.py", line 982, in __send_message
          helpers._check_command_response(first)
        File "/Users/shane/git/mongo-python-driver/pymongo/helpers.py", line 152, in _check_command_response
          raise CursorNotFound(errmsg, code, response)
      pymongo.errors.CursorNotFound: cursor id 56626714158 not found
      

      The full output is: python-1626-output.log

      Server version: 3.6.7

      $ mongodb-osx-x86_64-enterprise-3.6.7/bin/mongod --version
      db version v3.6.7
      git version: 2628472127e9f1826e02c665c1d93880a204075e
      OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018
      allocator: system
      modules: enterprise
      build environment:
          distarch: x86_64
          target_arch: x86_64
      

      Python version: 2.7
      PyMongo version: 3.7.1

        1. python-1626.py
          2 kB
        2. python-1626-output.log
          21 kB

            Assignee:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            5 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved: