Skip to content

[server] Fix prune index handling #1928 - #1929

Merged
michaelvlach merged 1 commit into
mainfrom
1928-server-fix-prune-index-handling
Sep 14, 2026
Merged

michaelvlach merged 1 commit into
mainfrom
1928-server-fix-prune-index-handling

Conversation

@michaelvlach

Copy link
Copy Markdown
Collaborator

No description provided.

@michaelvlach
michaelvlach requested review from agnesoft and a balanced review from Copilot September 14, 2026 14:01
@michaelvlach michaelvlach linked an issue Sep 14, 2026 that may be closed by this pull request
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agdb Ready Ready Preview Sep 14, 2026 2:01pm UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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(), set force_resync = true on 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_entries constructor (with new delegating to it) and an expect_needs_resync helper.
  • 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.

@michaelvlach
michaelvlach enabled auto-merge (squash) September 14, 2026 14:22
@michaelvlach
michaelvlach merged commit 830ea5d into main Sep 14, 2026
10 checks passed
@michaelvlach
michaelvlach deleted the 1928-server-fix-prune-index-handling branch September 14, 2026 14:47
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.

[server] Fix prune index handling

3 participants