v0.9.22
Summary:
- Fixed:
- 6ff217da prevent redundant election when single voter is already electing.
Detail:
Fixed:
-
Fixed: 6ff217da prevent redundant election when single voter is already electing; by Zhang Yanpo; 2026-04-08
When a single-voter node calls
elect()duringinitialize(), it
becomes a Candidate with an uncommitted vote. Before the vote flush
completes, an election tick can fire and trigger a secondelect(),
bumping the term unnecessarily (e.g., T1 → T2). This caused flaky
test failures insingle-term-leadermode wherenew_cluster()
expectedvote == <T1-N0:Q>but observed<T2-N0:Q>.The fix checks
candidate_ref().is_some()to detect an in-progress
election. This is precise because theCandidatestruct only exists
between anelect()call and becoming Leader — it is never present
after a node restart, unlike vote-based checks (is_leading()) which
would incorrectly match persisted votes from a previous run.