RUBY-3700 Do not clear pool on retryable errors#2990
Merged
comandeo-mongo merged 3 commits intomongodb:masterfrom Mar 3, 2026
Merged
RUBY-3700 Do not clear pool on retryable errors#2990comandeo-mongo merged 3 commits intomongodb:masterfrom
comandeo-mongo merged 3 commits intomongodb:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates connection-establishment error handling to support the client backpressure initiative by preventing SDAM state changes / pool clearing for retryable (backpressure-signaled) handshake network errors.
Changes:
- Add
SystemOverloadedError(andRetryableError) labeling to handshake network errors during connection establishment. - Skip marking the server Unknown (and thus skip pool clearing) when a handshake SocketError/SocketTimeoutError is labeled
SystemOverloadedError. - Add unified SDAM backpressure spec tests and adjust an existing CMAP spec test to use a command error instead of a forced connection close.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/mongo/server/pending_connection.rb |
Adds error labeling during handshake failures to support backpressure behavior. |
lib/mongo/server/connection_pool.rb |
Changes connection creation error handling to avoid unknown! (pool clear) for SystemOverloadedError-labeled handshake failures and to order events correctly. |
lib/mongo/server.rb |
Updates handshake failure handling to avoid unknown! when SystemOverloadedError is present. |
spec/mongo/server/connection_spec.rb |
Removes an expectation that handshake network errors mark the server unknown. |
spec/spec_tests/data/cmap/pool-create-min-size-error.yml |
Adjusts CMAP spec to use a command error (errorCode) for minPoolSize population error. |
spec/spec_tests/data/sdam_unified/backpressure-server-description-unchanged-on-min-pool-size-population-error.yml |
Adds unified SDAM test asserting server description doesn’t change on minPoolSize handshake backpressure error. |
spec/spec_tests/data/sdam_unified/backpressure-network-timeout-fail-single.yml |
Adds unified SDAM test asserting no pool clear + expected labels on handshake timeout backpressure. |
spec/spec_tests/data/sdam_unified/backpressure-network-timeout-fail-replicaset.yml |
Same as above for replicaset topology. |
spec/spec_tests/data/sdam_unified/backpressure-network-error-fail-single.yml |
Adds unified SDAM test asserting no pool clear + expected labels on handshake network error backpressure. |
spec/spec_tests/data/sdam_unified/backpressure-network-error-fail-replicaset.yml |
Same as above for replicaset topology. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jamis
approved these changes
Mar 3, 2026
comandeo-mongo
added a commit
to comandeo-mongo/mongo-ruby-driver
that referenced
this pull request
Mar 3, 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.
This PR is a part of the client backpressure initiative. Here we make sure that a connection pool is not cleared if a retryable error (in terms of the client backpressure spec) happens.