Skip to content

Commit

Permalink
Merge branch 'main' into tla-off-by-one
Browse files Browse the repository at this point in the history
  • Loading branch information
heidihoward authored Jan 8, 2024
2 parents 76dfd44 + 7cb07bb commit 907888c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion tla/consensus/MCccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ INVARIANTS
MonoLogInv
NoLeaderBeforeInitialTerm
LogConfigurationConsistentInv
MatchIndexLowerBoundSentIndexInv
CommitCommittableIndices
CommittableIndicesAreKnownSignaturesInv
1 change: 0 additions & 1 deletion tla/consensus/MCccfraftWithReconfig.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ INVARIANTS
MonoLogInv
NoLeaderBeforeInitialTerm
LogConfigurationConsistentInv
MatchIndexLowerBoundSentIndexInv
CommitCommittableIndices
CommittableIndicesAreKnownSignaturesInv
2 changes: 0 additions & 2 deletions tla/consensus/SIMccfraft.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ INVARIANTS
NoLeaderBeforeInitialTerm
LogConfigurationConsistentInv

MatchIndexLowerBoundSentIndexInv

CommitCommittableIndices

CommittableIndicesAreKnownSignaturesInv
Expand Down
13 changes: 11 additions & 2 deletions tla/consensus/ccfraft.tla
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ CandidateVarsTypeInv ==
/\ VotesGrantedTypeInv

\* The following variables are used only on leaders:
\* The last entry to send to each follower.

\* The last entry sent to each follower.
\* In CCF, the leader updates nextIndex optimically when an AE message is dispatched
\* In contrast, in Raft the leader only updates nextIndex when an AE response is received
VARIABLE sentIndex


SentIndexTypeInv ==
\A i, j \in Servers : i /= j =>
/\ sentIndex[i][j] \in Nat
Expand Down Expand Up @@ -919,7 +923,8 @@ HandleAppendEntriesResponse(i, j, m) ==
/\ m.success \* successful
\* max(...) because why would we ever want to go backwards on a success response?!
/\ matchIndex' = [matchIndex EXCEPT ![i][j] = max(@, m.lastLogIndex)]
/\ sentIndex' = [sentIndex EXCEPT ![i][j] = max(@, m.lastLogIndex)]
\* sentIndex is unchanged on successful AE response as it was already updated when the AE was dispatched
/\ UNCHANGED sentIndex
\/ /\ \lnot m.success \* not successful
/\ LET tm == FindHighestPossibleMatch(log[i], m.lastLogIndex, m.term)
IN sentIndex' = [sentIndex EXCEPT ![i][j] = max(min(tm, sentIndex[i][j]), matchIndex[i][j])]
Expand Down Expand Up @@ -1241,7 +1246,11 @@ NoLeaderBeforeInitialTerm ==
\A i \in Servers :
currentTerm[i] < StartTerm => state[i] # Leader

\* MatchIndexLowerBoundNextIndexInv is not currently an invariant but
\* we might wish to add it in the future. This could be achieved by updating
\* nextIndex to max of current nextIndex and matchIndex when an AE ACK is received.
MatchIndexLowerBoundSentIndexInv ==

\A i,j \in Servers :
state[i] = Leader =>
sentIndex[i][j] >= matchIndex[i][j]
Expand Down

0 comments on commit 907888c

Please sign in to comment.