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

Commit index may be smaller than snapshot index #1092

Open
Brokenice0415 opened this issue Mar 21, 2024 · 0 comments
Open

Commit index may be smaller than snapshot index #1092

Brokenice0415 opened this issue Mar 21, 2024 · 0 comments

Comments

@Brokenice0415
Copy link

Describe the bug

There will be a period of time when commit index may be smaller than snapshot index.

Steps to reproduce

Here is a possible trace.

0 become leader
0 commit = 56
0 send AE {57, 58, 59} to 2
2 reply 0, append {57, 58, 59}, update commit 56
0 add {60}
0 send AE {60} to 2
0 receive 2's reply, update commit 59
0 set snapshot_59
0 crash
2 receive 0, append {60}
2 become leader, add {61}
0 restart, commit reset to 0
2 send AE {61} to 0
0 update commit 56

# now 0's commit index 56 is smaller than snapshot index 59.

Possible solution

Since logs compacted by snapshot must have been committed, we can initialize the lastCommitIndex in BallotBox with the snapshot index (if exists) instead of 0.

Environment

  • SOFAJRaft version: master branch up to 19ed179
  • JVM version (e.g. java -version): 17.0.10
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