-
Type:
Build Failure
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: None
-
Component/s: Tests
-
None
-
Python Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
Name of Failure:
test.test_discovery_and_monitoring.TestPoolBackpressure.test_connection_pool_is_not_cleared
Link to task:
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