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

NRG (2.11): Use correct sequence when truncating to previous pterm/pindex #6073

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MauriceVanVeen
Copy link
Member

@MauriceVanVeen MauriceVanVeen commented Nov 4, 2024

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) and n.truncateWAL(eae.pterm, eae.pindex) combination would remove two entries, not just one. If the ae.pindex < n.pindex, the entry that has a matching ae.pindex is stored at stream sequence ae.pindex+1.

Signed-off-by: Maurice van Veen [email protected]

server/raft.go Outdated Show resolved Hide resolved
@MauriceVanVeen MauriceVanVeen force-pushed the maurice/truncate-down-to-commit branch 2 times, most recently from 91eae7f to bb57925 Compare November 4, 2024 16:48

// Heartbeat, makes sure we commit.
n.processAppendEntry(aeHeartbeat2, n.aesub)
require_Equal(t, n.commit, 3)
}

func TestNRGNewLeaderWithIncorrectPtermDoesNotTruncateIfCommitted(t *testing.T) {
Copy link
Member Author

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.

@MauriceVanVeen MauriceVanVeen changed the title NRG (2.11): Truncate down to commit NRG (2.11): Use correct sequence when truncating to previous pterm/pindex Nov 4, 2024
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.

2 participants