Skip to content

RUBY-3974 Send backpressure at top level of handshake - #3111

Merged
comandeo-mongo merged 5 commits into
mongodb:masterfrom
comandeo-mongo:3974-backpressure-top-level
Oct 7, 2026
Merged

comandeo-mongo merged 5 commits into
mongodb:masterfrom
comandeo-mongo:3974-backpressure-top-level

Conversation

@comandeo-mongo

@comandeo-mongo comandeo-mongo commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

The backpressure handshake field is sent nested inside the client
subdocument, but the client-backpressure and handshake specs require it as a
top-level field of the hello command. The server ignores it in the wrong
location, but strict client-metadata parsers such as monguard reject
connections whose client document contains the field.

Jira: https://jira.mongodb.org/browse/RUBY-3974

The client-backpressure and handshake specs require the backpressure
field to be a top-level field of the hello handshake command, not nested
in the client subdocument. The server ignores it in the wrong location,
but strict client-metadata parsers (monguard) reject connections from the
Ruby driver because of it.

Move backpressure out of client_document and into document, and update
the tests that asserted the old placement.
Implement handshake prose Test 9: intercept the handshake document and
assert it carries a top-level backpressure field set to "2". The driver
does not emit command monitoring events for the handshake, so add a
test-only recorder that wraps ConnectionCommon#handshake_document.

Also fill the gaps in handshake prose Test 1: add the invalid
AWS_EXECUTION_ENV case and the container-plus-FaaS case, and verify that
both the container and AWS Lambda metadata are present in client.env.

The client metadata update prose tests (1-8) are not implemented here:
they require the appendMetadata API tracked by RUBY-3655.
Monitor connections handshake on background threads while the test reads
the recorded documents on the main thread. Appending to a plain array
while iterating it works on MRI thanks to the GVL, but on JRuby a reader
can observe a slot that has been counted but not yet written, yielding a
nil element and failing with "undefined method '[]' for nil".

Guard appends with a mutex and return a snapshot instead of the live
array.
The test-only recorder reads handshake documents while monitor connections
write them from background threads. That race is benign on MRI but
surfaces as a nil element on JRuby, so skip the test there.
@comandeo-mongo
comandeo-mongo marked this pull request as ready for review October 6, 2026 08:18
@comandeo-mongo
comandeo-mongo requested a review from a team as a code owner October 6, 2026 08:18
@comandeo-mongo
comandeo-mongo requested a review from jamis October 6, 2026 08:18
@comandeo-mongo
comandeo-mongo merged commit 54b6b6c into mongodb:master Oct 7, 2026
240 of 241 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants