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

Fix snapshot initialization stuck issue #16

Merged
merged 1 commit into from
May 23, 2020
Merged

Conversation

kevinkassimo
Copy link
Contributor

@kevinkassimo kevinkassimo commented May 21, 2020

This is a strange bug we noticed. It seems from the example of raftexample, the code has 2 bugs:

  1. They replay records before loading snapshot, which would cause loss of records (snapshot overwrites store)
  2. When snapshot exists, the initial blocking readComments never exits, since the only condition to exit is on snap.ErrNoSnapshot, which will not happen as commitC <- nil only happens once while there exists snapshots.

This PR fixes this 2 issues by: differentiating initial load (where snapshot is immediately loaded instead of later), and directly return on receiving nil from commitC, instead of waiting indefinitely.

This fix is not very stable since there might be more strange issues with etcd's Raft API. The offending code is thus highlighted in case we have future issues here.

@kevinkassimo kevinkassimo requested a review from cy-b May 21, 2020 07:05
@cy-b cy-b merged commit 74d8f2f into master May 23, 2020
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

Successfully merging this pull request may close these issues.

2 participants