Skip to content

Raft Cluster: reconnect replicas when the primary address changes - #5733

Open
bandalgomsu wants to merge 3 commits into
valkey-io:cluster-v2from
bandalgomsu:cluster-v2/replica-primary-address
Open

bandalgomsu wants to merge 3 commits into
valkey-io:cluster-v2from
bandalgomsu:cluster-v2/replica-primary-address

Conversation

@bandalgomsu

Copy link
Copy Markdown
Contributor

When a Raft primary restarts with the same node ID on new ports, the cluster can report ok and show the new address in CLUSTER NODES while the replica keeps trying the old port. Reconnect the replica when it learns a new replication address for its current primary.

Tests

  • Verify that the replica reconnects after the primary restarts on new client and bus ports, before NODE_INFO can commit.
  • Verify that the replica reconnects when NODE_INFO propagates a live port change.

./runtest --single unit/cluster/cluster-raft passed.

A primary can restart with the same node ID and new ports. Raft
updates the node address while the replica keeps trying the old port.

Schedule a replication update when HELLO or NODE_INFO changes the
current primary address. Test each path and verify that the replica
reports the new port and brings the link back up.

Signed-off-by: Su Ko <rhtn1128@gmail.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddf50846-4776-4ed0-a1cd-8f0bb40d8da8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@valkey-review-bot

valkey-review-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Review state

Ready for human review.
The test-placement nit is fixed: the HELLO test now sits above the shard-epoch header, which is back directly over its tests. The retarget code in src/cluster_raft.c is unchanged since the last review and no new problems were found. The Tcl tests were not run here, and the test-cluster-raft CI job was still running on this commit.

Risk: Medium. A wrong retarget would drop a healthy replication link on a Raft-cluster replica or point it at a stale address, and a live port change now aborts a manual failover in progress.

Open findings: none.

Resolved (1)

  • (minor) tests/unit/cluster/cluster-raft-proto.tcl:1876 The new HELLO test block sat between the shard-epoch section header and the tests that header describes.

Backport: Not needed. src/cluster_raft.c exists only on the cluster-v2 branch (absent on upstream/9.2), so no release line carries this code.

Updated for a571d46 at 2026-12-05 10:12 UTC. The bot rewrites this comment on every review.

@bandalgomsu bandalgomsu self-assigned this Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.66%. Comparing base (b5d9651) to head (a571d46).
⚠️ Report is 3 commits behind head on cluster-v2.

Files with missing lines Patch % Lines
src/cluster_raft.c 95.65% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           cluster-v2    #5733      +/-   ##
==============================================
+ Coverage       81.62%   81.66%   +0.04%     
==============================================
  Files             203      203              
  Lines          108488   108514      +26     
==============================================
+ Hits            88553    88620      +67     
+ Misses          19935    19894      -41     
Files with missing lines Coverage Δ
src/cluster_raft.c 87.90% <95.65%> (+1.36%) ⬆️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/cluster_raft.c Resolved
Comment thread src/cluster_raft.c Resolved
Comment thread src/cluster_raft.c Resolved
Defer replication retargeting while the event loop is blocked and prefer committed addresses over HELLO. Cancel coordinated failover before reconnecting so a previously acknowledged write pause cannot be reused.

Signed-off-by: Su Ko <rhtn1128@gmail.com>
@bandalgomsu

Copy link
Copy Markdown
Contributor Author

thanks for the review! fixed all three in 658b55719

Signed-off-by: Su Ko <rhtn1128@gmail.com>
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.

2 participants