Repository navigation
Correctly set term field in Raft snapshot metadata - #5598
Merged
Merged
Conversation
ffuugoo
marked this pull request as ready for review
December 6, 2024 18:30
generall
approved these changes
Dec 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We recently (?) discovered a bug on chaos-testing, when the node might get "stuck" (e.g., consensus on this node does not progress) after applying Raft snapshot.
In the logs on chaos-testing I can see that Raft leader and "stuck" node get into a sort of infinite loop:
Storage::termmethod for this case specifically:latest_snapshot_metaindex, we return the term fromlatest_snapshot_metainstead of trying to read it from the WALlatest_snapshot_meta(for some reason) contains wrong term for operation 1337, then sanity check would keep rejecting operation 1337 every single time, and the node would get stuckSo, I've checked how we initialize snapshot metadata and tweaked our implementation to match example
MemStoragefromraftcrate.I did not reproduce the issue locally, but I think I know at least one possible scenario how it could happen: in most cases current commit index matches the current term, but right after new leader is elected, current term would be higher than term of operation at current commit index.
Anyway, this seems like a plausible fix, so I propose we merge this and see if the issue repro on chaos-testing again.
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --all --all-featurescommand?Changes to Core Features: