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

[store/meta]: add disk backed raft-state impl #1051

Closed
drmingdrmer opened this issue Jul 15, 2021 · 4 comments · Fixed by #1056
Closed

[store/meta]: add disk backed raft-state impl #1051

drmingdrmer opened this issue Jul 15, 2021 · 4 comments · Fixed by #1056
Assignees
Labels
C-feature Category: feature

Comments

@drmingdrmer
Copy link
Member

Summary

Persist raft state, which includes id, current_term and voted_for on disk.

This is the first step to impl the disk backed raft meta.
The next step is to impl disk-backed log and state machine.

Part of #271

@drmingdrmer drmingdrmer added the C-feature Category: feature label Jul 15, 2021
@drmingdrmer drmingdrmer self-assigned this Jul 15, 2021
@drmingdrmer drmingdrmer added this to the v0.5 milestone Jul 15, 2021
@jovany-wang
Copy link

Sorry for that I didn't understand the purpose to persist the metas.
In general cases, it's totally enough to persist log entries and user-defined state machines. Is there any context I have missed?

@drmingdrmer
Copy link
Member Author

There are some other information must be persisted, according to the raft paper, including the current term, and the leader a node has voted for.

E.g. if the voted_for get lost when restarting a raft node, there will be two nodes believes they are the legal leader.
Then the log get messed up:

R1 elect       become_leader                                  write_log1
   |                                                          |
   v                                                          v
R2 vote_for_R1               crash vote_for_R3                log1?log2?
                                   ^                          ^
                                   |                          |
R3                                 elect        become_leader write_log2
-------------------------------------------------------> time

@jovany-wang
Copy link

There are some other information must be persisted, according to the raft paper, including the current term, and the leader a node has voted for.

E.g. if the voted_for get lost when restarting a raft node, there will be two nodes believes they are the legal leader.
Then the log get messed up:

R1 elect       become_leader                                  write_log1
   |                                                          |
   v                                                          v
R2 vote_for_R1               crash vote_for_R3                log1?log2?
                                   ^                          ^
                                   |                          |
R3                                 elect        become_leader write_log2
-------------------------------------------------------> time

OK, I see.

@drmingdrmer
Copy link
Member Author

closed by #1056

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

Successfully merging a pull request may close this issue.

2 participants