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

Implicit sessions are not always discarded after network errors

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Resyncing the session spec tests in PYTHON-2075 led to this test failure:

      FAIL: test_sessions_dirty_session_errors_Dirty_implicit_session_is_discarded_(non-cursor_returning_read) (test.test_session.TestSpec)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/Users/shane/git/mongo-python-driver/test/__init__.py", line 444, in wrap
          return f(*args, **kwargs)
        File "/Users/shane/git/mongo-python-driver/test/__init__.py", line 444, in wrap
          return f(*args, **kwargs)
        File "/Users/shane/git/mongo-python-driver/test/test_session.py", line 1395, in run_scenario
          self.run_scenario(scenario_def, test)
        File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 641, in run_scenario
          self.run_test_ops(sessions, collection, test)
        File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 547, in run_test_ops
          self.run_operations(sessions, collection, test['operations'])
        File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 458, in run_operations
          self._run_op(sessions, collection, op, in_with_transaction)
        File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 448, in _run_op
          result = self.run_operation(sessions, collection, op.copy())
        File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 393, in run_operation
          result = cmd(**dict(arguments))
        File "/Users/shane/git/mongo-python-driver/test/test_session.py", line 1373, in assert_different_lsid_on_last_two_commands
          self.assertNotEqual(event1.command['lsid'], event2.command['lsid'])
      AssertionError: {'id': Binary(b'PY\x1f247@\x7f\x890!\x90\xd0\xfe\xb1\\', 4)} == {'id': Binary(b'PY\x1f247@\x7f\x890!\x90\xd0\xfe\xb1\\', 4)}
      

      The bug is that pymongo does not always mark an implicit session as "dirty" after a network error as required by the spec:

      If a driver has a server session pool and a network error is encountered when executing any command with a ClientSession, the driver MUST mark the associated ServerSession as dirty. Dirty server sessions are discarded when returned to the server session pool.

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

              Created:
              Updated:
              Resolved: