Raft's reuse of match_idx
can lead to unsafely advancing commit index
#5325
Labels
Milestone
match_idx
can lead to unsafely advancing commit index
#5325
As raised by @lemmy in #5321/#5324, we allow
match_idx
inraft.h
to go backwards in the implementation.As I suspected in this comment, this actually raises a larger safety concern. It goes backwards because we're using it to store a different concept, the probe index that reduces the number of NACKs to realign with a divergent log. But using that probe index to populate
match_idx
means the primary may overstate how far another node's log matches, and then use that overstatement to unsafely advance commit.Raft scenario repro proof here:
https://github.com/eddyashton/CCF/blob/match_idx_safety/tests/raft_scenarios/suffix_collision.3
In simpler terms (trying to ignore the surrounding partition complexity and additional nodes we need to reach this state, and almost certainly with some off-by-1s in doing this by-hand), we can have something like this:
match_idx[1] = 5
.I believe the fix is straightforward - store this probe index in a separate variable, and only set
match_idx
to safe matching values (received in ACKs).The text was updated successfully, but these errors were encountered: