Skip to content

RUBY-3778 Server deprioritizing in replica sets#2993

Merged
comandeo-mongo merged 1 commit intomongodb:masterfrom
comandeo-mongo:3778-fix-server-deprio
Mar 5, 2026
Merged

RUBY-3778 Server deprioritizing in replica sets#2993
comandeo-mongo merged 1 commit intomongodb:masterfrom
comandeo-mongo:3778-fix-server-deprio

Conversation

@comandeo-mongo
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 5, 2026 10:21
@comandeo-mongo comandeo-mongo requested a review from a team as a code owner March 5, 2026 10:21
@comandeo-mongo comandeo-mongo requested a review from jamis March 5, 2026 10:21
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

Updates retry server selection to avoid automatically deprioritizing the failed server in replica sets unless the retryable error indicates server overload (via the SystemOverloadedError label), while preserving existing behavior for sharded and load-balanced topologies.

Changes:

  • Add error-aware deprioritization logic to Mongo::Retryable.select_server (replica set: only when SystemOverloadedError label; sharded/load-balanced: always).
  • Pass the triggering error into retry server selection for both read and write retry paths (writes also track the most recent retry error).
  • Add integration coverage for replica set retry behavior with/without SystemOverloadedError label; update a unit spec cluster double to stub new topology predicates.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/mongo/retryable_spec.rb Stubs sharded?/load_balanced? on a cluster double to match new retry selection logic.
spec/integration/retryable_reads_errors_spec.rb Adds replica set integration tests asserting retry server changes based on SystemOverloadedError label.
lib/mongo/retryable/write_worker.rb Threads retry error context into server selection during write retries.
lib/mongo/retryable/read_worker.rb Threads original read error context into server selection during read retries.
lib/mongo/retryable.rb Implements error-aware server deprioritization (replica set vs sharded/load-balanced).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@comandeo-mongo comandeo-mongo merged commit 604b735 into mongodb:master Mar 5, 2026
174 of 175 checks passed
@comandeo-mongo comandeo-mongo deleted the 3778-fix-server-deprio branch March 5, 2026 16:37
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