-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
NRG (2.11): When term matches, simply truncate and store append entry #6073
Conversation
91eae7f
to
bb57925
Compare
|
||
// Heartbeat, makes sure we commit. | ||
n.processAppendEntry(aeHeartbeat2, n.aesub) | ||
require_Equal(t, n.commit, 3) | ||
} | ||
|
||
func TestNRGNewLeaderWithIncorrectPtermDoesNotTruncateIfCommitted(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.pindex
has 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