• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

databendlabs / openraft / 27400130554
87%

Build:
DEFAULT BRANCH: main
Ran 12 Jun 2026 07:02AM UTC
Jobs 1
Files 263
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Jun 2026 06:55AM UTC coverage: 86.642% (+0.02%) from 86.622%
27400130554

push

github

drmingdrmer
feat: config: Make leader restore upon restart configurable

# Summary

Add `Config::enable_leader_restore` to control whether a node that was a
leader before a restart resumes leadership at startup without an election.
The default (`true`) keeps the current behavior; `false` makes the node
restart as a follower and re-acquire leadership through a normal election,
as standard Raft does.

# Details

Openraft persists leadership in the committed vote, so a leader that
restarts quickly enough resumes serving without an election. This improves
availability, but the state machine may lose un-flushed state across the
restart and is rebuilt only up to the persisted committed index — and
persisting the committed index (`save_committed()`) is optional. The
restored leader can then serve reads from a state machine that is behind
what clients already observed, with no way for the application to detect
it (#1511).

Disabling leader restore closes this window: the restarted node rejoins as
a follower and catches up like any other follower before it can lead
again. This is useful when:

- the application does not persist the committed index, or the state
  machine is transient and rebuilt on startup;
- external readers require consistent reads across a leader restart;
- standard-Raft-compatible restart behavior is required.

Implementation:

- `enable_leader_restore` is `Option<bool>` resolved at runtime with
  `unwrap_or(true)` (same pattern as `allow_log_reversion`), so an unset
  value is distinguishable from an explicit choice.

- When disabled, `Engine::startup()` demotes the committed self-vote to
  non-committed in memory only; the committed vote intentionally stays in
  storage. Persisting the demoted vote would write a smaller value
  (non-committed < committed for the same leader), breaking the
  monotonicity of vote storage and of IO progress tracking. Keeping it is
  safe: votes order by leader id first, then committed flag, so no vote
  orders between ... (continued)

30 of 30 new or added lines in 4 files covered. (100.0%)

3 existing lines in 2 files now uncovered.

16533 of 19082 relevant lines covered (86.64%)

145669.23 hits per line

Coverage Regressions

Lines Coverage ∆ File
2
92.05
-0.22% openraft/src/core/raft_core.rs
1
83.33
0.0% openraft/src/metrics/serde_instant.rs
Jobs
ID Job ID Ran Files Coverage
1 27400130554.1 12 Jun 2026 07:02AM UTC 263
86.64
GitHub Action Run
Source Files on build 27400130554
  • Tree
  • List 263
  • Changed 7
  • Source Changed 4
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #27400130554
  • f4b5f61d on github
  • Prev Build on main (#27397846385)
  • Next Build on main (#27423417226)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc