Skip to content

fix(raft): pin openraft fork that resamples election timeout per campaign - #1845

Merged
bplatz merged 2 commits into
mainfrom
fix/raft-split-vote-livelock
Sep 16, 2026
Merged

bplatz merged 2 commits into
mainfrom
fix/raft-split-vote-livelock

Conversation

@bplatz

@bplatz bplatz commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Problem

After a three-voter group loses its leader, the two survivors can fail to elect a new one indefinitely. Each becomes a candidate at the same moment, votes for itself, and rejects the other's request as a competing vote in the same term. Both time out together and repeat, term after term. The two remaining voters are a healthy quorum, yet the group accepts no writes until something external changes the timing.

Solo's CI hit this in flow-raft's multi_node failover test, and reproduced it locally in about 8% of failovers. It applies to every group built on fluree-raft-core, including the data group.

Root cause

openraft 0.9 draws each node's random election timeout once, in EngineConfig::new when the Raft is constructed, and reuses it for every later campaign. Elections fire on a 75 ms tick. After a split round, each survivor's next deadline is its own fire time plus its own fixed timeout, so if both draws round to the same tick the gap between them never changes. The tie is a fixed point, not bad luck that eventually clears.

Upstream fixed this in databendlabs/openraft#1838, which resamples the timeout at the start of each campaign. It landed on the 0.10 line only. 0.9.25 does not include it.

Fix

The pin should be removed once a crates.io 0.9 release carries the resample fix. Solo's workspace needs the same patch entry to pick it up.

Tests

surviving_voters_elect_after_leader_loss in fluree-raft-core/tests/multi_node_group.rs runs 48 three-voter failovers over the HTTP transport, in six sequential batches of eight concurrent clusters. It shortens the election window to 250–500 ms so a shared tick is likely, then asserts that a survivor leads within 15 s.

openraft Runs passed Stalls observed
stock 0.9.24 0 of 5 Both survivors candidates in the same term, 32 to 48 terms deep
pinned fork 5 of 5 None across 240 failovers

The batches are kept small on purpose. With 48 clusters at once in a debug build, the runtime starves and vote responses miss the election window. Survivors then stall at diverging terms, which is a separate failure that also affects the fork, so the test must not produce it.

The raft-core integration suites only compile with --features testing,kv; run them with those features or they report zero tests.

…aign

openraft 0.9 draws the election timeout once, when the Raft is built. Two
surviving voters of a three-voter group whose draws round to the same
election tick start every campaign together after a leader loss, each
rejects the other's same-term vote request, and the split repeats term
after term with no leader elected.

Upstream fixed this on 0.10 only (databendlabs/openraft#1838). Pin
fluree/openraft release-0.9-fluree: v0.9.25 plus a port of that change.
The lockfile diff is limited to the openraft and openraft-macros entries.

surviving_voters_elect_after_leader_loss runs 48 three-voter failovers in
small concurrent batches with a 250-500 ms election window. Against stock
openraft at least one failover stalls with both survivors candidates in
the same term; against the pinned fork every failover elects a leader.
@bplatz bplatz added the bug Something isn't working as expected label Sep 15, 2026
@bplatz
bplatz requested review from aaj3f and zonotope September 15, 2026 12:09

@zonotope zonotope left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪭

Base automatically changed from fix/join-cancelled-reported-as-panic to main September 16, 2026 01:36
@bplatz
bplatz merged commit 3d89e8f into main Sep 16, 2026
16 checks passed
@bplatz
bplatz deleted the fix/raft-split-vote-livelock branch September 16, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants