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

ConfigurationError sending a command with an implicit session during race when topology no longer support sessions

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

      The sessions spec discusses several races that could occur when checking if a cluster supports sessions: https://github.com/mongodb/specifications/blob/a9096ad/source/sessions/driver-sessions.rst#possible-race-conditions-when-checking-whether-a-deployment-supports-sessions

      Pymongo does not implement this requirement:

      To handle these race conditions, the driver MUST ignore any implicit session if at the point it is sending a command to a specific server it turns out that that particular server doesn't support sessions after all.

      Additionally after the changes in PYTHON-2956, pymongo checks the topology for session support twice: first when creating the implicit session and a second time when "materializing" the server session object. The second check should be removed as it causes a ConfigurationError: Sessions are not supported by this MongoDB deployment error if the topology no longer supports sessions. As seen in HELP-41313

      Edit: This is the error in question:

      Traceback (most recent call last):
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/src/buildscripts/resmokelib/testing/hooks/tenant_migration.py", line 628, in _wait_for_reroute_or_test_completion
          doc = donor_primary_client["testTenantMigration"]["rerouted"].find_one(
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/collection.py", line 1459, in find_one
          for result in cursor.limit(-1):
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/cursor.py", line 1248, in next
          if len(self.__data) or self._refresh():
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/cursor.py", line 1165, in _refresh
          self.__send_message(q)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/cursor.py", line 1052, in __send_message
          response = client._run_operation(
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
          return func(self, *args, **kwargs)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1330, in _run_operation
          return self._retryable_read(
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
          return func(self, *args, **kwargs)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1448, in _retryable_read
          return func(session, server, sock_info, read_pref)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1326, in _cmd
          return server.run_operation(
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/server.py", line 100, in run_operation
          message = operation.get_message(read_preference, sock_info, use_cmd)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/message.py", line 387, in get_message
          spec = self.as_command(sock_info, apply_timeout=True)[0]
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/message.py", line 358, in as_command
          session._apply_to(cmd, False, self.read_preference, sock_info)
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/client_session.py", line 959, in _apply_to
          self._materialize()
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/client_session.py", line 953, in _materialize
          self._server_session = self._client._topology.get_server_session()
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/topology.py", line 566, in get_server_session
          session_timeout = self._check_session_support()
        File "/data/mci/ba7a8bb79aa8310ff27545993d5601d7/venv/lib/python3.10/site-packages/pymongo/topology.py", line 560, in _check_session_support
          raise ConfigurationError("Sessions are not supported by this MongoDB deployment")
      pymongo.errors.ConfigurationError: Sessions are not supported by this MongoDB deployment
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: