feat(v2): implement ReadIndex for linearizable reads #3619
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the ReadIndex in the Metastore to ensure linearizable reads, as described in the Raft consensus algorithm. The implementation leverages the Hashicorp Raft library's existing features while adding necessary checks to guarantee read consistency.
Key changes:
ReadIndex
method to verify leadership and return current commit index.readIndex
method to ensure the node is up-to-date before serving reads.QueryMetadata
andGetProfileStats
to usereadIndex
before querying data.CheckReady
method to usereadIndex
for consistency checks.Raft Algorithm Considerations:
runLeader
is called for the leader to be up to the latest commit index, which aligns with the Raft paper's recommendation for ensuring a committed entry from the current term (thanks @kolesnikovae for the heads up).Testing Considerations: