[Test failure] test.asynchronous.test_client_backpressure.AsyncTestClientBackpressure.test_05_overload_errors_with_basebackoffms_override_backoff

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.asynchronous.test_client_backpressure.AsyncTestClientBackpressure.test_05_overload_errors_with_basebackoffms_override_backoff

      Link to task:

      https://spruce.corp.mongodb.com/task/mongo_python_driver_pyopenssl_win64_test_standard_latest_python3.12_async_noauth_ssl_replica_set_cov_patch_48238a1a84dda761030d3d197ed70e1b64ea14a4_6a6a164fea4e0e0007859369_26_07_29_15_03_45/tests?execution=0&sorts=STATUS%3AASC

      Context of when and why the failure occurred:

      The absolute check is too sensitive on Windows platforms when running with async and Python <= 3.12.

      Stack trace:

      
      
      [2026/07/29 08:56:06.358] FAILURE: AssertionError: 0.29387570000000096 not greater than or equal to 0.3 ()
      [2026/07/29 08:56:06.358] self = <test.asynchronous.test_client_backpressure.AsyncTestClientBackpressure testMethod=test_05_overload_errors_with_basebackoffms_override_backoff>
      [2026/07/29 08:56:06.358] random_func = <MagicMock name='random' id='2459662818464'>
      [2026/07/29 08:56:06.358]     @unittest.skipIf(
      [2026/07/29 08:56:06.358]         sys.platform == "darwin",
      [2026/07/29 08:56:06.358]         "externalClientBaseBackoffMS is not supported on macOS",
      [2026/07/29 08:56:06.358]     )
      [2026/07/29 08:56:06.358]     @patch("random.random")
      [2026/07/29 08:56:06.358]     @async_client_context.require_version_min(9, 0, 0, -1)
      [2026/07/29 08:56:06.358]     @async_client_context.require_failCommand_appName
      [2026/07/29 08:56:06.358]     async def test_05_overload_errors_with_basebackoffms_override_backoff(self, random_func):
      [2026/07/29 08:56:06.358]         # Drivers should test that overload errors with `baseBackoffMS` override the default backoff duration.
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]         # 1. Let `client` be a `MongoClient`.
      [2026/07/29 08:56:06.358]         client = self.client
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]         # 2. Let `coll` be a collection.
      [2026/07/29 08:56:06.358]         coll = client.test.test
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]         # 3. Configure the random number generator used for exponential backoff jitter to always return a number as
      [2026/07/29 08:56:06.358]         # close as possible to `1`.
      [2026/07/29 08:56:06.358]         random_func.return_value = 1
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]         # 4. Configure the following failPoint:
      [2026/07/29 08:56:06.358]         fail_point = dict(
      [2026/07/29 08:56:06.358]             mode="alwaysOn",
      [2026/07/29 08:56:06.358]             data=dict(
      [2026/07/29 08:56:06.358]                 failCommands=["insert"],
      [2026/07/29 08:56:06.358]                 errorCode=462,
      [2026/07/29 08:56:06.358]                 errorLabels=["SystemOverloadedError", "RetryableError"],
      [2026/07/29 08:56:06.358]                 appName=self.app_name,
      [2026/07/29 08:56:06.358]             ),
      [2026/07/29 08:56:06.358]         )
      [2026/07/29 08:56:06.358]         async with self.fail_point(fail_point):
      [2026/07/29 08:56:06.358]             # 5. Insert the document `{ a: 1 }`. Expect that the command errors. Measure the duration of the command
      [2026/07/29 08:56:06.358]             # execution.
      [2026/07/29 08:56:06.358]             start0 = perf_counter()
      [2026/07/29 08:56:06.358]             with self.assertRaises(OperationFailure):
      [2026/07/29 08:56:06.358]                 await coll.insert_one({"a": 1})
      [2026/07/29 08:56:06.358]             end0 = perf_counter()
      [2026/07/29 08:56:06.358]             exponential_backoff_time = end0 - start0
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]             # 6. Run the following command to set up `baseBackoffMS` on overload errors.
      [2026/07/29 08:56:06.358]             try:
      [2026/07/29 08:56:06.358]                 await client.admin.command("setParameter", 1, externalClientBaseBackoffMS=50)
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]                 # 7. Execute step 5 again.
      [2026/07/29 08:56:06.358]                 start1 = perf_counter()
      [2026/07/29 08:56:06.358]                 with self.assertRaises(OperationFailure) as ctx:
      [2026/07/29 08:56:06.358]                     await coll.insert_one({"a": 1})
      [2026/07/29 08:56:06.358]                 end1 = perf_counter()
      [2026/07/29 08:56:06.358]                 with_base_backoff_ms_time = end1 - start1
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]                 # 8. Assert the server attached `baseBackoffMS` to the error and the driver parsed it.
      [2026/07/29 08:56:06.358]                 self.assertEqual(ctx.exception._base_backoff_ms, 50)
      [2026/07/29 08:56:06.358]             finally:
      [2026/07/29 08:56:06.358]                 # 9. Run the following command to disable `baseBackoffMS` on overload errors.
      [2026/07/29 08:56:06.358]                 await client.admin.command("setParameter", 1, externalClientBaseBackoffMS=0)
      [2026/07/29 08:56:06.358]     
      [2026/07/29 08:56:06.358]         # 10. Assert absolute bounds on each run's duration.
      [2026/07/29 08:56:06.358]         # A run can never be faster than the sum of its backoffs.
      [2026/07/29 08:56:06.358]         # With jitter pinned to 1, the default backoffs are 0.2 + 0.4 = 0.6s
      [2026/07/29 08:56:06.358]         # and the baseBackoffMS=50 backoffs are 0.1 + 0.2 = 0.3s.
      [2026/07/29 08:56:06.358]         self.assertGreaterEqual(exponential_backoff_time, 0.6)
      [2026/07/29 08:56:06.358] >       self.assertGreaterEqual(with_base_backoff_ms_time, 0.3)
      [2026/07/29 08:56:06.358] E       AssertionError: 0.29387570000000096 not greater than or equal to 0.3
      [2026/07/29 08:56:06.358] test\asynchronous\test_client_backpressure.py:358: AssertionError
      

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

              Created:
              Updated:
              Resolved: