Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLC throw an error while verifying Raft TLA+ spec #40

Open
kikimo opened this issue Dec 3, 2022 · 0 comments
Open

TLC throw an error while verifying Raft TLA+ spec #40

kikimo opened this issue Dec 3, 2022 · 0 comments

Comments

@kikimo
Copy link

kikimo commented Dec 3, 2022

While checking the Raft TLA+ spec in this repo, TLC throw an error reporting that:

Error: TLC threw an unexpected exception.
This was probably caused by an error in the spec or model.
See the User Output or TLC Console for clues to what happened.
The exception was a java.lang.RuntimeException
: Attempted to apply tuple
<<>>
to integer 1 which is out of domain.
Error: The behavior up to this point is:
...

The TLA+ code triggered this error was:

tla-plus/Raft/Raft.tla

Lines 354 to 361 in 8ae629d

/\ LET index == m.mprevLogIndex + 1
IN \/ \* already done with request
/\ \/ m.mentries = << >>
\/ /\ Len(log[i]) >= index
/\ log[i][index].term = m.mentries[1].term
\* This could make our commitIndex decrease (for
\* example if we process an old, duplicated request),
\* but that doesn't really affect anything.

The main problem is that TLC might still execute /\ log[i][index].term = m.mentries[1].term at line 358 even though m.mentries = << >> at line 356 is true(and that's how TLC evaluate an TLA+ expression). We might apply the patch below to fix the error:

 /\ LET index == m.mprevLogIndex + 1 
    IN \/ \* already done with request 
           /\ \/ m.mentries = << >> 
              \/ /\ Len(log[i]) >= index 
                 /\ m.mentries # << >>
                 /\ log[i][index].term = m.mentries[1].term 

PS: Is this repo still maintained? It seems that the TLA+ spec in this repo and the Raft implementation in TiKV have diverge quiet a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant