Repository navigation
Skip failed read candidates in MasterReplicaConnectionProvider #3502 - #3975
Merged
a-TODO-rov merged 4 commits intoOct 28, 2026
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
a-TODO-rov
previously requested changes
Oct 23, 2026
Contributor
Author
|
@a-TODO-rov Thanks for the review! I updated the branch since the earlier Redis 8.8 failure was in |
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.
Summary
With
ReadFromselecting more than one node (e.g.REPLICA_PREFERRED), a read fails withRedisConnectionExceptionas soon as one candidate cannot be connected, even when another candidate (often the master) is up. Fixes #3502.Behavioral / Conceptual Changes
firstOpenInOrderOrFallback(order-sensitiveReadFrom) skips candidates whose connection future failed instead of propagating the first failure.randomOpenOrFallbackno longer fails throughallOfwhen any candidate fails; it picks among the candidates that connected.This matches
PooledClusterConnectionProvider.getReadConnection, which already keeps the successful candidates and errors only when all of them fail.Testing
MasterReplicaConnectionProviderUnitTests: added tests for a failed replica with an order-sensitive and a randomReadFrom, for all candidates connecting, and for all candidates failing. Without the change, the two failed-replica tests fail.Also checked with a static Master/Replica setup on local Redis nodes (
MasterReplica.connectwith a static node list,REPLICA_PREFERRED): 7.8.0 fails the read in 3 of 4 scenarios with replicas down (1 of 1 replica down; 1 of 2 replicas down, depending on which is tried first; 2 of 2 down), while the master is up. With this change, all of them succeed.Make sure that:
mvn formatter:formattarget. Don’t submit any formatting related changes.Note
Medium Risk
Changes connection-selection logic for multi-node
ReadFromreads in master/replica mode; improves resilience but alters when reads fail vs. fall back to another node.Overview
Fixes master/replica read routing when
ReadFromyields multiple candidates (e.g.REPLICA_PREFERRED,ANY): a single unreachable replica no longer fails the read if another node connects.Order-sensitive selection (
firstOpenInOrderOrFallback) now treats failed connection futures as skippable viahandle, and falls back to the first successfully connected candidate instead of blindly usingconnections.get(0). Random selection (randomOpenOrFallback) waits on settled futures soallOfis not aborted by one failure, filters to open connections among those that connected, and uses the same fallback. A newfirstConnectedOrFailurehelper centralizes “first success or propagate first failure when all fail,” aligning behavior with cluster pooled read selection.Unit tests cover failed replica with order-sensitive and random
ReadFrom, replica preference when all connect, and failure only when every candidate fails.Reviewed by Cursor Bugbot for commit 94c9cf9. Bugbot is set up for automated code reviews on this repo. Configure here.