Skip to content

Implement prose backpressure tests#1946

Open
stIncMale wants to merge 2 commits intomongodb:backpressurefrom
stIncMale:backpressureProseTests
Open

Implement prose backpressure tests#1946
stIncMale wants to merge 2 commits intomongodb:backpressurefrom
stIncMale:backpressureProseTests

Conversation

@stIncMale
Copy link
Copy Markdown
Member

The relevant spec changes:

A concrete commit is specified instead of master because this is the last commit included in the DRIVERS-3160 Client Backpressure Support epic. Any newer commits are either irrelevant or are included in the DRIVERS-3337 Client Backpressure Improvements epic, which we do not care about for now.

AI usage

All modifications were done by the author. AI was used only to review the changes locally (Claude Code), and to review the GitHub PR (Copilot).

JAVA-5956, JAVA-6117, JAVA-6113, JAVA-6119, JAVA-6141

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Client Backpressure prose tests (per the linked spec) for both the synchronous driver and the reactive-streams driver (via the sync adapter).

Changes:

  • Introduce BackpressureProseTest functional tests in driver-sync, including failpoint-based retry/backpressure scenarios.
  • Add a driver-reactive-streams wrapper test class that reuses the sync prose tests by overriding client creation to use SyncMongoClient.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
driver-sync/src/test/functional/com/mongodb/client/BackpressureProseTest.java Adds failpoint-driven prose tests for overload retries/backoff behavior.
driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/BackpressureProseTest.java Reuses the sync prose tests for reactive streams by overriding createClient to return SyncMongoClient.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stIncMale stIncMale requested a review from nhachicha April 21, 2026 03:24
@stIncMale stIncMale marked this pull request as ready for review April 21, 2026 03:24
@stIncMale stIncMale requested a review from a team as a code owner April 21, 2026 03:24
@stIncMale stIncMale force-pushed the backpressureProseTests branch from 4c1a2da to 3eedce5 Compare April 21, 2026 03:31
Copy link
Copy Markdown
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment for review

}

private static Duration measureFailedInsertDuration(final MongoCollection<Document> collection, final boolean retryBackoff) {
if (!retryBackoff) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My codereview skill picked this up:

🟡 Timing assertion fragility (Test 1, L83-88) — Still stands. The measureFailedInsertDuration only configures the jitter supplier for the retryBackoff == false case (commented-out line 87: setTestJitterSupplier(() -> 0)). The retryBackoff == true path has no corresponding jitter override, meaning it will use random jitter when enabled, making the 300ms variance window non-deterministic.

Per the spec, the backoff-enabled measurement should also use a controlled jitter value (close to 1). This will need an else branch when the TODO is uncommented.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Done in eb753df.

The crazy part is that I was sure the following step

iv. Configure the random number generator used for jitter to always return a number as close as possible to 1.

does not exist...

This is a 100% valid concern from the standpoint of "implement the damn test the way it is specified". However, given that jitter is guaranteed to be <= 1 when it is random, and that the 300 ms maxTotalBackoffMillis is computed for the upper jitter bound of 1, specifying jitter supplier 1 changes absolutely nothing for the test.

@stIncMale stIncMale removed the request for review from nhachicha April 21, 2026 15:11
@stIncMale stIncMale requested a review from rozza April 21, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants