[server] Fix prune index handling #1928 - #1929
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🔵 Needs a closer look
The change alters distributed consensus resync/pruning recovery behavior — a safety-critical path — and addresses the symptom rather than the root-cause prune_index calculation named in the issue, so it warrants human sign-off.
Pull request overview
This PR fixes a cluster-resync bug in the raft consensus layer (issue #1928). When a leader's prune_index is stale after a restart (e.g., reinit() recomputes it as commit - max_log_entries, which can be lower than the actual amount of pruning that occurred in a previous session), a follower that needs already-pruned log entries would fall into a gap that the prune safety-net (prune_index > log_commit) does not catch. Previously reconcile() detected this gap, logged a warning, and returned None without taking any corrective action, leaving the follower stuck. The fix makes reconcile() set the target node's force_resync flag when a gap is detected, which is then propagated via the next heartbeat so the follower triggers a full resync — matching the existing pattern used for the append-failure threshold path.
Changes:
- In
reconcile(), setforce_resync = trueon the target node when a log gap is detected, and update the warning message to reflect the new "Forcing resync." behavior. - Add a
TestCluster::with_max_log_entriesconstructor (withnewdelegating to it) and anexpect_needs_resynchelper. - Add unit and integration tests covering the gap-detection resync path.
File summaries
| File | Description |
|---|---|
agdb_server/src/raft.rs |
reconcile() now flags force_resync on gap detection; adds test helpers and unit/integration tests validating the resync-on-gap behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
No description provided.