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

databendlabs / openraft / 29395441618
87%

Build:
DEFAULT BRANCH: main
Ran 15 Jul 2026 06:56AM UTC
Jobs 1
Files 265
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

15 Jul 2026 06:51AM UTC coverage: 87.464% (+0.007%) from 87.457%
29395441618

push

github

drmingdrmer
fix: ignore election trigger on the current Leader

# Summary

`Raft::trigger().elect()` on a node that is already the Leader is now a no-op.
It previously started a campaign the Leader could not win, costing the group its
Leader and inflating the term for nothing.

# Details

Campaigning does not tear down the internal Leader. `state.vote` moves to the
new, uncommitted term, but the node is still leading under that vote, so
`leader` survives with `committed_vote` at the old term. The node keeps
heartbeating from that stale leadership, which keeps refreshing the voters'
leader leases -- and an unexpired lease is exactly what makes them reject the
vote request the campaign just sent. The campaign cannot succeed, and repeating
the trigger only repeats the loop. The old code acknowledged the gap with a
`// TODO: reject if it is already a leader?`.

That split state is invalid on its own terms as well: `LeaderHandler` does not
expect `leader.committed_vote` to trail `state.vote`. `do_elect()` now asserts
that leadership is relinquished before a campaign begins, so a future caller
that reintroduces the state fails loudly in debug builds. Leadership transfer is
unaffected: the broadcast skips the sender, so the target is still a Follower
when it campaigns.

The unit test for repeated campaigns built its starting state out of a Leader,
which the new precondition forbids; it now drives two real campaigns instead. A
new integration test covers triggering on a live Leader, with and without
Pre-Vote.

2 of 3 new or added lines in 1 file covered. (66.67%)

6 existing lines in 3 files now uncovered.

17561 of 20078 relevant lines covered (87.46%)

157528.31 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
97.02
-0.18% openraft/src/engine/engine_impl.rs

Coverage Regressions

Lines Coverage ∆ File
3
88.89
-3.7% openraft/src/core/sm/handle.rs
2
92.76
-0.21% 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 29395441618.1 15 Jul 2026 06:56AM UTC 265
87.46
GitHub Action Run
Source Files on build 29395441618
  • Tree
  • List 265
  • Changed 7
  • Source Changed 3
  • Coverage Changed 7
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #29395441618
  • 4490c678 on github
  • Prev Build on release-0.10 (#29306675071)
  • Next Build on main (#29396608459)
  • 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