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 checking assertion of Leadership #626

Closed
wants to merge 1 commit into from

Conversation

otoolep
Copy link
Contributor

@otoolep otoolep commented Oct 17, 2024

This allows clients of this library to check if the current node, assuming it is the Leader, has explicitly asserted leadership in the current term. "Asserting" is defined has having committed at least one log entry in the current term, as per the Raft paper.

This change adds a new channel, which is only serviced when in Leadership mode. This channel will respond with the asserted status via a Future. Clients are recommended to call this function only until they have confirmed that the leadership has been asserted. Once asserted for a given term the state can be cached until the end of the term.

This code is necessary to properly implement the Read Optimization outlined in the Raft paper and dissertation. The dissertation explains that it is not sufficient to simply check the Leader's commit index. Instead a client must first confirm that the Leader has explicitly asserted leadership by committing a log entry in the current term. Only then is commit index valid.

This allows clients of this library to check if the current node, assuming it is the Leader, has explicitly asserted leadership in the current term. "Asserting" is defined has having committed at least one log entry in the current term, as per the Raft paper.

This change adds a new channel, which is only serviced when in Leadership mode. This channel will respond with the asserted status via a Future. Clients are recommended to call this function only until they have confirmed that the leadership has been asserted. Once asserted for a given term the state can be cached until the end of the term.

This code is necessary to properly implement the Read Optimization outlined in the Raft paper and dissertation. The dissertation explains that it is not sufficient to simply check the Leader's commit index. Instead a client must first confirm that the Leader has explicitly asserted leadership by committing a log entry in the current term. Only then is commit index valid.
@otoolep otoolep requested review from a team as code owners October 17, 2024 23:09
@otoolep otoolep requested review from rboyer and removed request for a team October 17, 2024 23:09
@otoolep otoolep closed this Oct 17, 2024
@otoolep otoolep deleted the assert-leadership branch October 17, 2024 23:09
@otoolep otoolep restored the assert-leadership branch October 17, 2024 23:10
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.

1 participant