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

Support consistent read with leader lease #804

Open
Tracked by #806
drmingdrmer opened this issue Apr 28, 2023 · 1 comment
Open
Tracked by #806

Support consistent read with leader lease #804

drmingdrmer opened this issue Apr 28, 2023 · 1 comment

Comments

@drmingdrmer
Copy link
Member

drmingdrmer commented Apr 28, 2023

Openraft has a mechanism called leader lease. This mechanism ensures that a follower does not elect itself as a leader before a certain period of time, which is determined by adding the timer_config.leader_lease + timer_config.election_timeout. The follower refreshes the lease by updating the last-updated-time of the vote. However, the current issue is that the leader does not update the lease yet.

To support reading consistent state, openraft needs to :

  • The leader should extend its lease when a log is accepted by a quorum.
  • and add a public API such as Raft::read(sm: &mut impl RaftStateMachine) that atomically checks leader lease and reads some data from the state machine.

https://github.com/datafuselabs/openraft/blob/54154202beec3e2de433044baae505cc80db375b/openraft/src/core/raft_core.rs#L1345-L1357

https://github.com/datafuselabs/openraft/blob/54154202beec3e2de433044baae505cc80db375b/openraft/src/engine/handler/vote_handler/mod.rs#L124

Originally posted by @drmingdrmer in #262 (comment)

@github-actions
Copy link

👋 Thanks for opening this issue!

Get help or engage by:

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

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