Add baseBackoffMS support - #2052
Draft
vbabanin wants to merge 8 commits into
Draft
Conversation
Add a 9.0 entry to the version axis and include 9.0 in all test matrix variants that currently test against 8.0, mirroring the Python and Node drivers. This gives the backpressure baseBackoffMS override prose test (Test 5, gated on serverVersionAtLeast(9, 0)) a pinned CI variant to run against.
vbabanin
force-pushed
the
baseBackoffMS-support
branch
from
September 11, 2026 00:03
a424287 to
1e202c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR brings the driver's Client Backpressure implementation up to date with the latest
specification changes: the server-supplied
baseBackoffMSoverride, the correctedexponential backoff formula exponent, and the versioned
backpressure: "2"handshakeflag. Also adds MongoDB 9.0 to the Evergreen version matrix so the new 9.0-gated
prose test has a CI variant to run against.
Tickets
baseBackoffMSserver override, handshakebackpressure: "2"Upstream spec commits:
d6fc118(DRIVERS-3535)615e0f9(DRIVERS-3578)Commits
a8c755e829407b3f0430ac31095dc99b6d1a499564d1a438b1d5377190cd7a42e3ac5b5472e7b055Changes
Backoff formula exponent (JAVA-6238 / DRIVERS-3535)
The spec changed the exponential backoff to use the retry number directly as the
exponent, instead of one less than the retry number:
jitter * min(MAX_BACKOFF, BASE_BACKOFF * 2^attempt)(was2^(attempt-1))→ first retry 200ms, second 400ms (was 100ms / 200ms).
jitter * min(BACKOFF_INITIAL * 1.5^attempt, BACKOFF_MAX)(was
1.5^(attempt-1)).Both share
ExponentialBackoff.calculateBackoffMs, so a single-line exponent fixcovers both.
BASE_BACKOFFremains 100ms;MAX_BACKOFFremains 10000ms.Server-supplied
baseBackoffMSoverride (JAVA-6238 / DRIVERS-3535)When an overload error document contains a positive top-level
baseBackoffMSfield,the driver now uses it in place of the 100ms
BASE_BACKOFFconstant:ExponentialBackoff.calculateOverloadBackoff(int, @Nullable Long baseBackoffMs)overload. A
nullor non-positive value falls back to the 100ms default; a positivevalue replaces it. The 10000ms cap is preserved.
SpecRetryPolicyextractsbaseBackoffMSfromMongoCommandException.getResponse()and passes it through. Extraction is lenient: absent, non-numeric, or non-positive
values are ignored.
Handshake
backpressure: "2"(JAVA-6238 / DRIVERS-3535)The handshake now sends
backpressure: "2"— the BSON string"2", not a booleanand not the number 2 — to version the supported backpressure specification. Previously
the driver sent
backpressure: true. The value is sent unconditionally on every hello(no server-version gating), matching the Python and Node reference implementations;
the flag is currently unused by the server and older servers ignore unexpected
handshake field values.
Test updates
BackpressureProseTest.operationRetryUsesExponentialBackoff):expected overload backoff sum 0.3s → 0.6s.
BackpressureProseTest.overloadErrorsWithBaseBackoffMsOverrideBaseBackoff):verifies
baseBackoffMSoverrides the default backoff. Gated onserverVersionAtLeast(9, 0); pins jitter to 1, togglesexternalClientBaseBackoffMSviasetParameter, and asserts timing bounds(default run ≥ 600ms; override run ≥ 300ms and < 600ms).
AbstractClientMetadataProseTest): asserts thebackpressurefield is the string"2".WithTransactionProseTest.testRetryBackoffIsEnforced):expected sum of 13 backoffs 1800ms → 2300ms.
ExponentialBackoffTest): updated the transaction backoff expectedarray for the new exponent; added 4 tests covering the
baseBackoffMSoverride(default-when-absent, positive-override, non-positive-ignored, max-cap-preserved).
InternalStreamConnectionInitializerSpecification): updatedthe 4 handshake expectations to
backpressure: "2".Evergreen (JAVA-6238)
Added a
9.0entry to theversionaxis in.evergreen/.evg.ymland included9.0in all test matrix variants that currently test against
8.0, mirroring the Pythonand Node drivers. This gives the 9.0-gated prose Test 5 a pinned CI variant. The
Atlas-specific
MONGODB_VERSION: "8.0"deploy target is left untouched (Atlasmanages its own server version).