[v25.3.x] raft: refresh election timer on recovery-path append_entries (pre-vote livelock) - #31255
Merged
bharathv merged 1 commit intoAug 11, 2026
Conversation
A follower that is behind a live leader can get stuck in a perpetual pre-vote storm. `should_skip_vote` suppresses elections only while `_hbeat` (last leader contact) is within one election timeout, but in `do_append_entries` the `_hbeat` refresh lives on the successful batch-append path (a deferred update). The two early returns that fire when the follower is behind, log gap (prev_log_index > last_log_offset) and prev-log-term mismatch, call maybe_update_leader() and reply to the leader but never refresh `_hbeat`. So a follower in continuous contact with the current-term leader, but unable to append because it is still being recovered, lets its election timer expire, starts a (pre-)vote that deterministically fails the longest-log check (log_ok=false), rearms, and repeats. The storm burns CPU that further starves recovery, a self-reinforcing livelock that leaves partitions under-replicated and stalls acks=all produce with REQUEST_TIMED_OUT. Refresh `_hbeat` as soon as an append_entries from the current-term leader is accepted (right after maybe_update_leader), covering the recovery early-return paths as well as the success path. This matches the existing design intent noted in vote_request handling, where the comment states `_hbeat` is updated by the leader. Liveness is preserved: if the leader is actually gone, no append_entries arrive, `_hbeat` goes stale, and elections proceed as before. Fixes redpanda-data#30815 Signed-off-by: Steven Pall <mail@stevenpall.ca> (cherry picked from commit 81f445b)
bharathv
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #30817
Conflict details
Fixes: #31254,