Skip to content

Cluster primary node map is not refreshed on slot renewal, so primary-only commands go to demoted nodes after failover - #4692

Merged
ggivo merged 1 commit into
redis:masterfrom
insaf021:cluster-primary-cache-renew
Aug 21, 2026
Merged

ggivo merged 1 commit into
redis:masterfrom
insaf021:cluster-primary-cache-renew

Conversation

@insaf021

@insaf021 insaf021 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

JedisClusterInfoCacheTest, failover replayed through renewClusterSlots instead of discoverClusterNodesAndSlots:

Expected: map containing ["127.0.0.1:7001"->...]
     but: map was [<127.0.0.1:7000=...>]

And against the cluster-stable docker env after CLUSTER FAILOVER on :7483:

primaries after     : [localhost:7479, localhost:7480, localhost:7481]
FLUSHALL -> JedisBroadcastException ... (2 succeeded, 1 failed; first error: READONLY You can't write against a read only replica.)
   localhost:7479 -> JedisDataException: READONLY You can't write against a read only replica.

primaryNodesCache is only written by discoverClusterNodesAndSlots, which runs once at construction. Every later refresh (MOVED handling, the topology-refresh timer, refreshClusterTopology()) goes through discoverClusterSlots, which rebuilds slots and prunes dead nodes but leaves the primary map as it was, so ALL_SHARDS broadcasts, keyless writes and getConnection() keep targeting the pre-failover primaries. Rebuild the map in the same write-locked block, as the initial discovery already does. With the change the run above ends in [localhost:7480, localhost:7481, localhost:7483] and FLUSHALL -> OK.

Fixes #4691.


Note

Cursor Bugbot is generating a summary for commit 36ed766. Configure here.

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ggivo
ggivo merged commit ecfed3d into redis:master Aug 21, 2026
19 of 20 checks passed
ggivo added a commit that referenced this pull request Aug 21, 2026
…oCache.discoverClusterSlots (#4695)

refresh primaryNodesCache in JedisClusterInfoCache.discoverClusterSlots (#4692)

(cherry picked from commit ecfed3d)

Co-authored-by: insaf021 <Insaf@digiscrypt.com>
ggivo added a commit that referenced this pull request Aug 21, 2026
…oCache.discoverClusterSlots (#4694)

refresh primaryNodesCache in JedisClusterInfoCache.discoverClusterSlots (#4692)

(cherry picked from commit ecfed3d)

Co-authored-by: insaf021 <Insaf@digiscrypt.com>
@ggivo ggivo added this to the 8.1.0 milestone Aug 28, 2026
@ggivo ggivo changed the title refresh primaryNodesCache in JedisClusterInfoCache.discoverClusterSlots Cluster primary node map is not refreshed on slot renewal, so primary-only commands go to demoted nodes after failover Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster primary node map is not refreshed on slot renewal, so primary-only commands go to demoted nodes after failover

2 participants