raft: avoid stale leadership transfer targets - #972
Conversation
|
Warning Review limit reached
More reviews will be available in 5 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a Changesraftadmin status command
Dispatch drop reporting to raft event loop
Rolling-update leadership-transfer lag-based candidate selection
Sequence Diagram(s)sequenceDiagram
participant Shell as rolling-update.sh
participant raftadmin as raftadmin_text / raft_status
participant LeaderNode as Leader Node gRPC
participant FollowerNode as Follower Node gRPC
Shell->>raftadmin: raft_status(leader_addr)
raftadmin->>LeaderNode: Status RPC
LeaderNode-->>raftadmin: commit_index, last_log_index, snapshot_index, peer list
raftadmin-->>Shell: parsed status output
Shell->>Shell: choose_transfer_candidate: filter/rank peers by log lag
loop each candidate in ranked order
Shell->>FollowerNode: LeaderTransfer(candidate_id)
alt transfer succeeds
FollowerNode-->>Shell: ok
Shell->>Shell: proceed with restart
else transfer fails
Shell->>Shell: try next candidate
end
end
Shell->>Shell: all candidates failed → abort restart
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new status command to the raftadmin CLI to query detailed Raft status, and updates the etcd raft engine to report dropped dispatch messages to the event loop. Additionally, the rolling-update.sh script is updated to leverage this new status command to select leadership transfer candidates based on log lag, avoiding stale peers. The review feedback highlights two issues in the shell script: first, the error output is omitted when the leader status check fails, and second, a failed status check on followers is masked by || true and incorrectly parsed, which could lead to misleading logs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@codex review Addressed Gemini findings on
Validation after the fix:
|
|
@codex review PR is now ready for review. Gemini threads were fixed in
|
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/rolling-update.sh`:
- Around line 979-981: Update the documentation in rolling-update.env.example
(around lines 76-81) to reflect that the generic transfer fallback behavior has
been removed. The current documentation still mentions "falling back to generic
transfer" as part of the retry behavior, but this is no longer accurate since
the code now refuses generic transfer and returns with error status when all
targeted candidates are exhausted. Modify the documentation to clearly state
that the restart will abort if all targeted leadership transfer attempts fail,
removing any reference to the fallback behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 73fb569d-e6af-46e8-9d76-fb7f0026636e
📒 Files selected for processing (5)
cmd/raftadmin/main.gocmd/raftadmin/main_test.gointernal/raftengine/etcd/dispatch_report_test.gointernal/raftengine/etcd/engine.goscripts/rolling-update.sh
|
@codex review Addressed CodeRabbit docs feedback in Validation:
|
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
raftadmin statusso rollout can inspect raft log indexesTests
go test ./cmd/raftadmin ./internal/raftengine/etcdbash -n scripts/rolling-update.sh && git diff --checkgo test ./adapter -run '^TestRedis_MisskeyConnectionCompatibility$' -count=1 -timeout=2m\n-go test ./...fails:adapterpackage timed out after 600s\nSummary by CodeRabbit
New Features
statuscommand to raftadmin CLI tool providing cluster state informationImprovements
Tests