Skip to content

Commit

Permalink
matchIndex is monotonically increasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmy committed Jun 6, 2023
1 parent 42ca603 commit 5b6b146
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tla/ccfraft.tla
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,15 @@ HandleAppendEntriesRequest(i, j, m) ==
HandleAppendEntriesResponse(i, j, m) ==
/\ \/ /\ m.term = currentTerm[i]
/\ m.success \* successful
/\ nextIndex' = [nextIndex EXCEPT ![i][j] = m.lastLogIndex + 1]
/\ matchIndex' = [matchIndex EXCEPT ![i][j] = m.lastLogIndex]
\* max(...) because why would we ever want to go backwards on a success response?!
/\ matchIndex' = [matchIndex EXCEPT ![i][j] = max(@, m.lastLogIndex)]
/\ nextIndex' = [nextIndex EXCEPT ![i][j] = max(@, m.lastLogIndex + 1)]
\/ /\ \lnot m.success \* not successful
/\ LET tm == FindHighestPossibleMatch(log[i], m.lastLogIndex, m.term)
IN nextIndex' = [nextIndex EXCEPT ![i][j] =
(IF matchIndex[i][j] = 0 THEN tm ELSE min(tm, matchIndex[i][j])) + 1 ]
\* UNCHANGED matchIndex is implied by the following statement in figure 2, page 4 in the raft paper:
\* "If AppendEntries fails because of log inconsistency: decrement nextIndex and retry"
/\ UNCHANGED matchIndex
/\ Discard(m)
/\ UNCHANGED <<reconfigurationVars, commitsNotified, serverVars, candidateVars, logVars>>
Expand Down

0 comments on commit 5b6b146

Please sign in to comment.