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

Draft: Simplify RaftStorage API #432

Closed
drmingdrmer opened this issue Jul 5, 2022 · 2 comments
Closed

Draft: Simplify RaftStorage API #432

drmingdrmer opened this issue Jul 5, 2022 · 2 comments
Labels
draft Unfinished issue

Comments

@drmingdrmer
Copy link
Member

There are 3 parts of data RaftStorage that raft needs to access:

  • meta:

    vote: Vote
    membership_state: {committed, effective}
    
  • raft-log:

    • list of entries
    • meta: range: (purged, last]
  • state-machine:

    • user defined data.
    • meta: last_applied

Membership in Raft can be considered as another slot of logs. And only at most two membership logs need to be stored:

Thus internally, raft has two log-and-state-machine structures: user log and its state machine and membership log and its state machine.
The membership state machine is simply a record of the committed membership.
Thus the membership-log and membership-state-machine can be merged into one meta-record: membership_state.
This way the user-data-state-machine does not need to store membership in it.

RaftStorage {
  // infrequently updated meta data: vote and membership.
  write_meta()
  read_meta()
  
  // log
  append()
  purge()
  truncate()
  get_log_state()

  // state machine
  apply()
  get_last_applied_log_id()
  
  // snapshot
  install_snapshot()
  build_snapshot()
}
@drmingdrmer drmingdrmer added the draft Unfinished issue label Jul 5, 2022
@github-actions
Copy link

github-actions bot commented Jul 5, 2022

👋 Thanks for opening this issue!

Get help or engage by:

  • /help : to print help messages.
  • /assignme : to assign this issue to you.

@drmingdrmer
Copy link
Member Author

The storage API has been splitted into RaftLogStorage and RaftStateMachine since 0.9

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

No branches or pull requests

1 participant