[BF] test_connection_pool_is_not_cleared

XMLWordPrintableJSON

    • Type: Build Failure
    • Resolution: Fixed
    • Priority: Unknown
    • 4.18.0
    • Affects Version/s: None
    • Component/s: Tests
    • None
    • Python Drivers
    • Not Needed
    • 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_discovery_and_monitoring.TestPoolBackpressure.test_connection_pool_is_not_cleared

      Link to task:

      https://spruce.corp.mongodb.com/task/mongo_python_driver_pyopenssl_rhel8_test_standard_rapid_python3.13_sync_auth_ssl_sharded_cluster_4eb4d6dc5b5811d841c9e6c85b6dec67c0b992a2_26_07_06_12_30_01/tests?execution=0&sorts=STATUS%3AASC

      Context of when and why the failure occurred:

      We had previously addressed this failure in PYTHON-5875 by calling setParameter on each mongos, but the test failed even when merging that fix.

      Stack trace:

      [2026/07/06 07:54:38.104] FAILURE: AssertionError: 3 != 0 ()
      [2026/07/06 07:54:38.104] self = <test.test_discovery_and_monitoring.TestPoolBackpressure testMethod=test_connection_pool_is_not_cleared>
      [2026/07/06 07:54:38.104]     @client_context.require_version_min(7, 0, 0)
      [2026/07/06 07:54:38.104]     @unittest.skipIf(
      [2026/07/06 07:54:38.104]         sys.platform == "darwin" and "CI" in os.environ,
      [2026/07/06 07:54:38.104]         "PYTHON-5861: $where is too slow on macOS CI",
      [2026/07/06 07:54:38.104]     )
      [2026/07/06 07:54:38.104]     def test_connection_pool_is_not_cleared(self):
      [2026/07/06 07:54:38.104]         listener = CMAPListener()
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Create a client that listens to CMAP events, with maxConnecting=100.
      [2026/07/06 07:54:38.104]         client = self.rs_or_single_client(maxConnecting=100, event_listeners=[listener])
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # setParameter needs to be set on each mongos in a sharded cluster
      [2026/07/06 07:54:38.104]         if client_context.mongoses:
      [2026/07/06 07:54:38.104]             admin_clients = [
      [2026/07/06 07:54:38.104]                 self.single_client("{}:{}".format(*address)) for address in client_context.mongoses
      [2026/07/06 07:54:38.104]             ]
      [2026/07/06 07:54:38.104]         else:
      [2026/07/06 07:54:38.104]             admin_clients = [client]
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Disable the ingress rate limiter on teardown.
      [2026/07/06 07:54:38.104]         # Sleep for 1 second before disabling to avoid the rate limiter.
      [2026/07/06 07:54:38.104]         def teardown():
      [2026/07/06 07:54:38.104]             time.sleep(1)
      [2026/07/06 07:54:38.104]             for admin_client in admin_clients:
      [2026/07/06 07:54:38.104]                 admin_client.admin.command(
      [2026/07/06 07:54:38.104]                     "setParameter", 1, ingressConnectionEstablishmentRateLimiterEnabled=False
      [2026/07/06 07:54:38.104]                 )
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         self.addCleanup(teardown)
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Enable the ingress rate limiter.
      [2026/07/06 07:54:38.104]         for admin_client in admin_clients:
      [2026/07/06 07:54:38.104]             admin_client.admin.command(
      [2026/07/06 07:54:38.104]                 "setParameter", 1, ingressConnectionEstablishmentRateLimiterEnabled=True
      [2026/07/06 07:54:38.104]             )
      [2026/07/06 07:54:38.104]             admin_client.admin.command(
      [2026/07/06 07:54:38.104]                 "setParameter", 1, ingressConnectionEstablishmentRatePerSec=20
      [2026/07/06 07:54:38.104]             )
      [2026/07/06 07:54:38.104]             admin_client.admin.command(
      [2026/07/06 07:54:38.104]                 "setParameter", 1, ingressConnectionEstablishmentBurstCapacitySecs=1
      [2026/07/06 07:54:38.104]             )
      [2026/07/06 07:54:38.104]             admin_client.admin.command(
      [2026/07/06 07:54:38.104]                 "setParameter", 1, ingressConnectionEstablishmentMaxQueueDepth=1
      [2026/07/06 07:54:38.104]             )
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Make sure the collection has at least one document.
      [2026/07/06 07:54:38.104]         client.test.test.delete_many({})
      [2026/07/06 07:54:38.104]         client.test.test.insert_one({})
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Run a slow operation to tie up the connection.
      [2026/07/06 07:54:38.104]         def target():
      [2026/07/06 07:54:38.104]             try:
      [2026/07/06 07:54:38.104]                 client.test.test.find_one({"$where": delay(0.1)})
      [2026/07/06 07:54:38.104]             except ConnectionFailure:
      [2026/07/06 07:54:38.104]                 pass
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Run 100 parallel operations that contend for connections.
      [2026/07/06 07:54:38.104]         tasks = []
      [2026/07/06 07:54:38.104]         for _ in range(100):
      [2026/07/06 07:54:38.104]             tasks.append(ConcurrentRunner(target=target))
      [2026/07/06 07:54:38.104]         for t in tasks:
      [2026/07/06 07:54:38.104]             t.start()
      [2026/07/06 07:54:38.104]         for t in tasks:
      [2026/07/06 07:54:38.104]             t.join()
      [2026/07/06 07:54:38.104]     
      [2026/07/06 07:54:38.104]         # Verify there were at least 10 connection checkout failed event but no pool cleared events.
      [2026/07/06 07:54:38.104]         self.assertGreater(len(listener.events_by_type(ConnectionCheckOutFailedEvent)), 10)
      [2026/07/06 07:54:38.104] >       self.assertEqual(len(listener.events_by_type(PoolClearedEvent)), 0)
      [2026/07/06 07:54:38.104] E       AssertionError: 3 != 0
      [2026/07/06 07:54:38.104] test/test_discovery_and_monitoring.py:524: AssertionError
      

            Assignee:
            Steve Silvester
            Reporter:
            Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: