[Build Failure] test.test_server_selection_in_window.TestProse.test_load_balancing

XMLWordPrintableJSON

    • Type: Build Failure
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: 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_server_selection_in_window.TestProse.test_load_balancing

      Link to task:

      https://spruce.corp.mongodb.com/task/mongo_python_driver_mongodb_v4.4_test_server_version_python3.14t_sync_auth_ssl_sharded_cluster_bb7a81f1e01d00d9534da0c114f9e7b9f9f76b7c_26_06_30_13_42_02/tests?execution=0&sorts=STATUS%3AASC

      Context of when and why the failure occurred:

      Historically flaky test that was not made entirely deterministic by PYTHON-3689. Possibly a free-threading issue with the event publishing performed by the test.

      Stack trace:

      
      
      [2026/06/30 07:03:17.913] FAILURE: AssertionError: 99 != 100 ()
      [2026/06/30 07:03:17.913] self = <test.test_server_selection_in_window.TestProse testMethod=test_load_balancing>
      [2026/06/30 07:03:17.913]     @client_context.require_failCommand_appName
      [2026/06/30 07:03:17.913]     @client_context.require_multiple_mongoses
      [2026/06/30 07:03:17.913]     @unittest.skipIf(
      [2026/06/30 07:03:17.913]         sys.platform == "darwin" and platform.machine() == "arm64" and "CI" in os.environ,
      [2026/06/30 07:03:17.913]         "PYTHON-5861: Load balancing frequency assertion is timing-sensitive on macOS ARM64 CI",
      [2026/06/30 07:03:17.913]     )
      [2026/06/30 07:03:17.913]     def test_load_balancing(self):
      [2026/06/30 07:03:17.913]         listener = OvertCommandListener()
      [2026/06/30 07:03:17.913]         cmap_listener = CMAPListener()
      [2026/06/30 07:03:17.913]         # PYTHON-2584: Use a large localThresholdMS to avoid the impact of
      [2026/06/30 07:03:17.913]         # varying RTTs.
      [2026/06/30 07:03:17.913]         client = self.rs_client(
      [2026/06/30 07:03:17.913]             client_context.mongos_seeds(),
      [2026/06/30 07:03:17.913]             appName="loadBalancingTest",
      [2026/06/30 07:03:17.913]             event_listeners=[listener, cmap_listener],
      [2026/06/30 07:03:17.913]             localThresholdMS=30000,
      [2026/06/30 07:03:17.913]             minPoolSize=10,
      [2026/06/30 07:03:17.913]         )
      [2026/06/30 07:03:17.913]         wait_until(lambda: len(client.nodes) == 2, "discover both nodes")
      [2026/06/30 07:03:17.913]         # Wait for both pools to be populated.
      [2026/06/30 07:03:17.913]         cmap_listener.wait_for_event(ConnectionReadyEvent, 20)
      [2026/06/30 07:03:17.913]         # Delay find commands on only one mongos.
      [2026/06/30 07:03:17.913]         delay_finds = {
      [2026/06/30 07:03:17.913]             "configureFailPoint": "failCommand",
      [2026/06/30 07:03:17.913]             "mode": {"times": 10000},
      [2026/06/30 07:03:17.913]             "data": {
      [2026/06/30 07:03:17.913]                 "failCommands": ["find"],
      [2026/06/30 07:03:17.913]                 "blockConnection": True,
      [2026/06/30 07:03:17.913]                 "blockTimeMS": 500,
      [2026/06/30 07:03:17.913]                 "appName": "loadBalancingTest",
      [2026/06/30 07:03:17.913]             },
      [2026/06/30 07:03:17.913]         }
      [2026/06/30 07:03:17.913]         coll = client.test.test
      [2026/06/30 07:03:17.913]         N_TASKS = 10
      [2026/06/30 07:03:17.913]         with self.fail_point(delay_finds):
      [2026/06/30 07:03:17.913]             nodes = client_context.client.nodes
      [2026/06/30 07:03:17.913]             self.assertEqual(len(nodes), 1)
      [2026/06/30 07:03:17.913]             delayed_server = next(iter(nodes))
      [2026/06/30 07:03:17.913]             # Start background tasks to build up op_count on the delayed server.
      [2026/06/30 07:03:17.913]             # This ensures the measurement phase sees a stable op_count imbalance
      [2026/06/30 07:03:17.913]             # rather than a 50/50 random distribution from equal initial counts.
      [2026/06/30 07:03:17.913]             background_tasks = [FinderTask(coll, 1) for _ in range(N_TASKS)]
      [2026/06/30 07:03:17.913]             for task in background_tasks:
      [2026/06/30 07:03:17.913]                 task.start()
      [2026/06/30 07:03:17.913]             # Wait until all background finds are dispatched so the delayed
      [2026/06/30 07:03:17.913]             # server's finds are in-flight (each blocked for 500ms).
      [2026/06/30 07:03:17.913]             wait_until(
      [2026/06/30 07:03:17.913]                 lambda: len(listener.started_events) >= N_TASKS,
      [2026/06/30 07:03:17.913]                 "background tasks to dispatch finds",
      [2026/06/30 07:03:17.913]             )
      [2026/06/30 07:03:17.913]             # Measure distribution while the delayed server is busy.
      [2026/06/30 07:03:17.913]             listener.reset()
      [2026/06/30 07:03:17.913] >           freqs = self.frequencies(client, listener)
      [2026/06/30 07:03:17.913]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      [2026/06/30 07:03:17.913] test/test_server_selection_in_window.py:193: 
      [2026/06/30 07:03:17.913] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      [2026/06/30 07:03:17.913] test/test_server_selection_in_window.py:131: in frequencies
      [2026/06/30 07:03:17.913]     self.assertEqual(len(events), n_finds * N_TASKS)
      [2026/06/30 07:03:17.913] E   AssertionError: 99 != 100
      

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

              Created:
              Updated:
              Resolved: