NRG (2.11): When term matches, simply truncate and store append entry#6073
Merged
derekcollison merged 1 commit intomainfrom Nov 11, 2024
Merged
NRG (2.11): When term matches, simply truncate and store append entry#6073derekcollison merged 1 commit intomainfrom
derekcollison merged 1 commit intomainfrom
Conversation
91eae7f to
bb57925
Compare
MauriceVanVeen
commented
Nov 4, 2024
| require_Equal(t, n.commit, 3) | ||
| } | ||
|
|
||
| func TestNRGNewLeaderWithIncorrectPtermDoesNotTruncateIfCommitted(t *testing.T) { |
Member
Author
There was a problem hiding this comment.
These two tests that have been removed asserted that n.pterm = n.term could still be executed, resulting in a situation where we should recover from the possibility of having an incorrect pterm.
Since its removal in #6060, these tests should be removed. We should never have this situation occur anymore.
bb57925 to
998d7d0
Compare
998d7d0 to
a9c30c3
Compare
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
a9c30c3 to
7a10f66
Compare
neilalexander
approved these changes
Nov 11, 2024
Member
neilalexander
left a comment
There was a problem hiding this comment.
LGTM, this is effectively the approach Maurice and I were talking about at the end of last week, where we can avoid having to wait for a heartbeat to apply an entry after a truncation, and additionally where we can prune the log back step-by-step if needed until we can resolve a pterm mismatch.
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.
If we are leader and store two entries, the first having quorum and being committed/applied and the second not having quorum. A new leader should be able to truncate the second entry.
That was not possible before as the
n.loadEntry(ae.pindex)andn.truncateWAL(eae.pterm, eae.pindex)combination would remove two entries, not just one.We now check if the entry stored at
ae.pindexhas a matching term withae.pterm, if so we can truncate entries past that point and then simply continue storing that append entry. Instead of needing to truncate, stop, get a heartbeat, start catchup, get the same append entry again, store it, get the next entry, stop catchup, etc. In this case we can now just, truncate and store.Signed-off-by: Maurice van Veen github@mauricevanveen.com