RUBY-3741 Support deprioritizing for all topologies#2984
Merged
comandeo-mongo merged 1 commit intomongodb:masterfrom Feb 6, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements server deprioritization for all MongoDB topologies as part of the client backpressure initiative (DRIVERS-3160). The changes enable retry operations to avoid repeatedly selecting the same failing servers by deprioritizing them during server selection.
Changes:
- Added deprioritization filtering that occurs before read/write preference evaluation
- Implemented fallback logic to select deprioritized servers when no other suitable servers are available
- Added comprehensive test coverage including 8 new server selection test cases
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/mongo/server_selector/base.rb | Core implementation: refactored suitable_servers to apply deprioritization filtering through candidates method, added fallback logic for when all suitable servers are deprioritized |
| spec/runners/server_selection.rb | Updated test runner to support deprioritized_servers parameter and added skip logic for one known failing test case |
| spec/spec_tests/server_selection_spec.rb | Added SKIPPED_TESTS configuration to skip DeprioritizedAllSecondaryPreferred test pending RUBY-3768 resolution |
| spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/*.yml | Added 8 new test cases covering deprioritization scenarios across different read preferences (Primary, PrimaryPreferred, Secondary, SecondaryPreferred, Nearest) including edge cases like state changes and all-servers-deprioritized |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jamis
approved these changes
Feb 5, 2026
Contributor
jamis
left a comment
There was a problem hiding this comment.
👍
There are some test failures, but they appear spurious.
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 enables server deprioritization on retry attempts for all topologies and apply deprioritized filtering before applying read/write preferences during server selection.
This PR is a part of client backpressure initiative - https://jira.mongodb.org/browse/DRIVERS-3160