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

Question about the TestLeaderCommitEntry2AB #465

Open
onford opened this issue Jan 21, 2025 · 3 comments
Open

Question about the TestLeaderCommitEntry2AB #465

onford opened this issue Jan 21, 2025 · 3 comments

Comments

@onford
Copy link

onford commented Jan 21, 2025

The annotation before function TestLeaderCommitEntry2AB(at raft_paper_test.go) says that:

The leader keeps track of the highest index it knows to be committed, and it includes that index in future AppendEntries RPCs so that the other servers eventually find out.

I have no idea what "includes that index in future AE RPCs" means. Won't this cause inconsistency in committed among peers? For example, the last index for entries in the Leader's RaftLog is 12, and the leader knows through AppendEntriesResponce RPC from other peers that the entry with index 11 has been replicated in a majority of peers, then the leader assign 12 to committed. However, the followers currently do not know the fact that index 12 is committed, so they keep the origin committed, and this origin committed is obviously less than 12. The inconsistency will disappear when followers receive new AE RPCs, while the inconsistency may recover when the leader receives AER RPCs again.

So what is the actual mechanism for committed to communicate among peers?

@Connor1996
Copy link
Collaborator

"it includes that index in future AE RPCs" means leader put the commit index in the later AppendEntries.

The inconsistency will disappear when followers receive new AE RPCs, while the inconsistency may recover when the leader receives AER RPCs again.
Yes, the commit index would keep updating until no new writes. The inconsistency is okay, it doesn't break anything.

@onford
Copy link
Author

onford commented Jan 22, 2025

@Connor1996 Thanks for your reply! However, the inconsistency will cause test case TestLeaderSyncFollowerLog2AB in raft_paper_test.go to fail, since the leader's committed index is different from that of follower, as is indicated in #457 by a kind friend. If I do not misunderstand this mechanism, maybe the test logic for TestLeaderSyncFollowerLog2AB has a subtle problem?

@onford
Copy link
Author

onford commented Jan 22, 2025

@Connor1996 Thanks for your reply! However, the inconsistency will cause test case TestLeaderSyncFollowerLog2AB in raft_paper_test.go to fail, since the leader's committed index is different from that of follower, as is indicated in #457 by a kind friend. If I do not misunderstand this mechanism, maybe the test logic for TestLeaderSyncFollowerLog2AB has a subtle problem?

I think it will work by letting the leader send an extra MsgHeartbeat RPC, which makes the commit indexes synchronized when there's no entry to append.

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

2 participants