Ordering issue between event publish and logging in test.test_connection_logging.TestConnectionLoggingConnectionPoolOptions.test_waitQueueTimeoutMS_should_be_included_in_connection_pool_created_message_when_specified

XMLWordPrintableJSON

    • Type: Build Failure
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Name of Failure:

      test.test_connection_logging.TestConnectionLoggingConnectionPoolOptions.test_waitQueueTimeoutMS_should_be_included_in_connection_pool_created_message_when_specified

      Link to task:

      https://spruce.corp.mongodb.com/task/mongo_python_driver_mongodb_v7.0_test_server_version_pypy3.11_sync_noauth_nossl_standalone_cov_patch_575d75f4d3c690bb4b5562e7bd896e5547548f96_69fb60d8e2e6050007c95908_26_05_06_15_40_10/tests?execution=0&sorts=STATUS%3AASC

      Context of when and why the failure occurred:

      Known flaky test. The root cause here is that Pool events are published before the corresponding logs are. In the synchronous API, this can cause the following ordering issue in tests:
      1. Test calls wait_until to poll for the event being published
      2. Pool publishes the event
      3. Before the log can be published, the thread running wait_until preempts the Pool's thread and sees that the event has been published. This causes the test to run its assertions, which fail since the log has not been emitted.

      Stack trace:

      
      
      [2026/05/06 08:50:19.626] FAILURE: AssertionError: 2 != 1 : expected [{'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool created', 'serverHost': {'$$type': 'string'}, 'serverPort': {'$$type': ['int', 'long']}, 'waitQueueTimeoutMS': 10000}}, {'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool ready', 'serverHost': {'$$type': 'string'}, 'serverPort': {'$$type': ['int', 'long']}}}] but got [{'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool created', 'clientId': ObjectId('69fb61c657b07497d93cd9fa'), 'serverHost': 'localhost', 'serverPort': 27017, 'waitQueueTimeoutMS': 10000.0}}] ()
      [2026/05/06 08:50:19.626] self = <test.test_connection_logging.TestConnectionLoggingConnectionPoolOptions testMethod=test_waitQueueTimeoutMS_should_be_included_in_connection_pool_created_message_when_specified>
      [2026/05/06 08:50:19.626]     def test_case(self):
      [2026/05/06 08:50:19.626] >       self.run_scenario(spec)
      [2026/05/06 08:50:19.626] test/unified_format.py:1538: 
      [2026/05/06 08:50:19.626] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      [2026/05/06 08:50:19.626] test/unified_format.py:1473: in run_scenario
      [2026/05/06 08:50:19.626]     self._run_scenario(spec, uri)
      [2026/05/06 08:50:19.626] test/unified_format.py:1512: in _run_scenario
      [2026/05/06 08:50:19.626]     self.check_log_messages(spec["operations"], expect_log_messages)
      [2026/05/06 08:50:19.626] test/unified_format.py:1416: in check_log_messages
      [2026/05/06 08:50:19.626]     self.assertEqual(
      [2026/05/06 08:50:19.626] E   AssertionError: 2 != 1 : expected [{'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool created', 'serverHost': {'$$type': 'string'}, 'serverPort': {'$$type': ['int', 'long']}, 'waitQueueTimeoutMS': 10000}}, {'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool ready', 'serverHost': {'$$type': 'string'}, 'serverPort': {'$$type': ['int', 'long']}}}] but got [{'level': 'debug', 'component': 'connection', 'data': {'message': 'Connection pool created', 'clientId': ObjectId('69fb61c657b07497d93cd9fa'), 'serverHost': 'localhost', 'serverPort': 27017, 'waitQueueTimeoutMS': 10000.0}}]
      

            Assignee:
            Noah Stapp
            Reporter:
            Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: