Repository navigation
RUBY-3974 Send backpressure at top level of handshake - #3111
Merged
comandeo-mongo merged 5 commits intoOct 7, 2026
Merged
Conversation
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.
This reverts commit 1359a8a.
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.
jamis
approved these changes
Oct 6, 2026
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.
The
backpressurehandshake field is sent nested inside theclientsubdocument, 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
clientdocument contains the field.Jira: https://jira.mongodb.org/browse/RUBY-3974