Skip to content

RUBY-3700 Do not clear pool on retryable errors#2990

Merged
comandeo-mongo merged 3 commits intomongodb:masterfrom
comandeo-mongo:3700-avoid-clearing-pool
Mar 3, 2026
Merged

RUBY-3700 Do not clear pool on retryable errors#2990
comandeo-mongo merged 3 commits intomongodb:masterfrom
comandeo-mongo:3700-avoid-clearing-pool

Conversation

@comandeo-mongo
Copy link
Contributor

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.

Copilot AI review requested due to automatic review settings March 3, 2026 08:42
@comandeo-mongo comandeo-mongo requested a review from a team as a code owner March 3, 2026 08:42
@comandeo-mongo comandeo-mongo requested a review from jamis March 3, 2026 08:42
Copy link
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

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 (and RetryableError) 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.

comandeo-mongo and others added 2 commits March 3, 2026 11:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@comandeo-mongo comandeo-mongo merged commit cc37229 into mongodb:master Mar 3, 2026
171 checks passed
@comandeo-mongo comandeo-mongo deleted the 3700-avoid-clearing-pool branch March 3, 2026 16:33
comandeo-mongo added a commit to comandeo-mongo/mongo-ruby-driver that referenced this pull request Mar 3, 2026
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