Skip to content

CSHARP-6089: Client Backpressure with baseBackoffMS#2065

Draft
papafe wants to merge 5 commits into
mongodb:mainfrom
papafe:csharp6089
Draft

CSHARP-6089: Client Backpressure with baseBackoffMS#2065
papafe wants to merge 5 commits into
mongodb:mainfrom
papafe:csharp6089

Conversation

@papafe

@papafe papafe commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

https://jira.mongodb.org/browse/CSHARP-6089

Implements spec PR mongodb/specifications#1953:

  • Handshake backpressure field changes from true to the literal string "2".
  • A server-supplied retryAfterMS on an overload error overrides the default backpressure backoff base.

Draft: the spec PR (#1953) is still open, and the server field is slated to be renamed retryAfterMSbaseBackoffMS (SERVER-130142).

This PR will need to be finalised after the spec PR has been merged. This includes updating the comments on tests.

@papafe papafe added the feature Adds new user-facing functionality. label Jul 7, 2026
@papafe papafe changed the title CSHARP-6089: Client Backpressure with retryAfterMS CSHARP-6089: Client Backpressure with baseBackoffMS Jul 8, 2026
papafe added 4 commits July 13, 2026 10:08
Update the exponential-backoff formula from 2^(attempt-1) to 2^attempt
per the client-backpressure and transactions-convenient-api spec change
(mongodb/specifications#1953), and update the dependent backoff tests.
Also adds the baseBackoffMS overload integration test.
…and adapt tests to the new OperationContext API

- Add Feature.ClientBackpressureBaseBackoffMs (wire version Server90) and
  gate the integration test on it instead of a server-version string, so it
  runs on 9.0 pre-release servers rather than skipping until GA.
- Adopt the updated spec test 5 shape (absolute backoff bounds + assert the
  driver parsed baseBackoffMS) for the mocked unit test.
- Fix GetOperationRetryBackoffDelay test bounds for the 2^attempt exponent.
- Adapt tests to the CSHARP-6011 change (Session moved onto OperationContext;
  OperationContext(TimeSpan, CancellationToken) and NoTimeout removed).
The async retry path slept the full backpressure backoff via
Task.Delay(backoff, operationContext.CancellationToken), which does not
fire when the CSOT deadline elapses, so a large server-supplied
baseBackoffMS could overshoot the deadline by seconds and surface a late
TimeoutException. Add the same early-bail guard the sync path already has
(throw the original overload error when the backoff would exceed the
remaining timeout), matching the client-backpressure spec's deadline
check. Add regression tests to both executor test suites and correct the
AGENTS.md note that wrongly claimed the async path needed no guard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds new user-facing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant