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): Truncate entries without quorum from different pterm #6027

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

MauriceVanVeen
Copy link
Member

@MauriceVanVeen MauriceVanVeen commented Oct 21, 2024

Reverts the changes made in #5987, but the tests are kept.

Instead opting for a simpler approach:

  • removing the isNew condition when pterm or pindex don't match, to ensure consistency even during catchup
  • move the ae.pindex == n.pindex condition up so pterm can be corrected (otherwise it would not be executed)

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

@@ -3383,35 +3383,37 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {
n.updateLeadChange(false)
}

if (isNew && ae.pterm != n.pterm) || ae.pindex != n.pindex {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing isNew makes sure we can also detect differences if we're catching up, otherwise we could wrongly assume our own state is correct.

Specifically covered by the test TestNRGWALEntryWithoutQuorumMustTruncate/diverged

@@ -3434,16 +3436,6 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) {
return
}

// Check if only our terms do not match here.
if ae.pindex == n.pindex {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition could never be hit before, due to the condition above:

// Check if this is a lower or equal index than what we were expecting.
if ae.pindex <= n.pindex {

Now moved up so the pterm can be corrected, otherwise we could spin.

Already covered by the test TestJetStreamClusterStreamCatchupNoState. Previously it used a different way to pass, likely truncating a bit too much and eventually converging. Now it only corrects the pterm as truncating is not needed.

server/raft.go Outdated Show resolved Hide resolved
Copy link
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, have spoken to @MauriceVanVeen about some of the changes here and I think they're OK. Should be simpler than the previous approach of starting catchups at n.commit.

Copy link
Contributor

@mprimi mprimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about some of these changes, but if you and Neil are confident, so am i.

It would be easier to review if each commit was atomic / self-contained and the commit message explained what the intent / reason was.

You have some comments in GH which is convenient, but if you look at this commit in a month will you find them?
Unlike GH comments, commit messages become part of history along with the change.

server/raft.go Outdated Show resolved Hide resolved
server/raft.go Show resolved Hide resolved
server/raft.go Show resolved Hide resolved
server/raft_helpers_test.go Show resolved Hide resolved
@MauriceVanVeen MauriceVanVeen force-pushed the maurice/simplify-truncate-entries-without-quorum branch from df79a38 to f9d2cc4 Compare October 22, 2024 18:46
@MauriceVanVeen MauriceVanVeen changed the title NRG (2.11): Simplify catchup & truncate NRG (2.11): Truncate entries without quorum from different pterm Oct 24, 2024
@MauriceVanVeen MauriceVanVeen marked this pull request as ready for review October 24, 2024 18:10
@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner October 24, 2024 18:10
@derekcollison
Copy link
Member

@mprimi you good with this PR?

@mprimi
Copy link
Contributor

mprimi commented Oct 24, 2024

@derekcollison yes, we reviewed this morning and i am onboard.

@derekcollison derekcollison merged commit 7680add into main Oct 24, 2024
5 checks passed
@derekcollison derekcollison deleted the maurice/simplify-truncate-entries-without-quorum branch October 24, 2024 21:51
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.

4 participants