fix raft election safety defects from #155 - #158
Merged
Merged
Conversation
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.
Summary
Fixes three of the four Raft election defects in #155.
become_followerclearedvoted_foron every step-down, so the node could grant a second vote in the same term.last_heartbeat_time = 0against wall-clock milliseconds meant every node's timer was already expired at startup, so joiners campaigned within ~100 ms.tick(0)to replay committed entries, which setstartup_time = 0, so a node without peers elected itself immediately. It now usestake_committed().Full-mesh startup now waits one election timeout (3–5 s) before the first election, so settle time goes from 8–9 s to 11–14 s.
Test plan
cargo make clippycargo make testelection_timeout_is_redrawn_for_every_electionpins re-randomization on every election (review finding: an earlier revision of this branch dropped it)mqdb dev testownership, sharing and presence: pass, twice each.--all: passes twice. Its constraints step is timing-dependent: it can hit the existing 503 "unique reservation not yet durable" window, which lasts 5–143 s on main