fix(consensus): advance raft befor stopping consensus

Allows the log index to increase and a peer to be elected as leader.

Signed-off-by: Anton Antonov <anton.synd.antonov@gmail.com>
This commit is contained in:
Anton Antonov
2026-09-21 12:38:24 +03:00
parent 1677df4767
commit ec5278ff6b
+5 -2
View File
@@ -1435,12 +1435,15 @@ impl Consensus {
let stop_consensus = handle_committed_entries(&committed_entries, &store, &mut self.node)
.context("Failed to handle committed entries")?;
// Advance the Raft regardless of `stop_consensus`: raft-rs requires every `Ready` to be
// advanced, and this node's own removal does not exempt it from that contract, even
// though nothing reads the returned `LightReady` once consensus is stopping.
let light_rd = self.node.advance(ready);
if stop_consensus {
return Ok((None, None, false));
}
// Advance the Raft.
let light_rd = self.node.advance(ready);
Ok((Some(light_rd), role_change, is_idle))
}