[FIXED] NRG: New entries from old leader reset WAL during catchup#7209
Merged
neilalexander merged 1 commit intomainfrom Aug 26, 2025
Merged
[FIXED] NRG: New entries from old leader reset WAL during catchup#7209neilalexander merged 1 commit intomainfrom
neilalexander merged 1 commit intomainfrom
Conversation
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
MauriceVanVeen
commented
Aug 25, 2025
| n.debug("Term higher than ours and we are not a follower: %v, stepping down to %q", n.State(), ae.leader) | ||
| n.stepdownLocked(ae.leader) | ||
| } | ||
| } else if lterm < n.term && sub != nil && (isNew || ae.lterm != 0) { |
Member
Author
There was a problem hiding this comment.
This whole block was moved up, only this statement was changed from:
} else if lterm < n.term && sub != nil && !(catchingUp && ae.lterm == 0) {
neilalexander
added a commit
that referenced
this pull request
Sep 1, 2025
Responding to a lower term was removed in #7209, as it assumed the leader would already respond with this information. However, if this server is a candidate, it would need to be the one rejecting and sending back the response. This PR fixes that, and adds a test to ensure it stays that way. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
MauriceVanVeen
pushed a commit
that referenced
this pull request
Sep 3, 2025
A follower could be running catchup and then receive "new" very delayed entries from an old leader. This would result in one entry being allowed through to truncate or reset the WAL, while subsequent old entries would be rejected. This would result in desync if the current leader had already committed the entry at that index. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
MauriceVanVeen
pushed a commit
that referenced
this pull request
Sep 3, 2025
Responding to a lower term was removed in #7209, as it assumed the leader would already respond with this information. However, if this server is a candidate, it would need to be the one rejecting and sending back the response. This PR fixes that, and adds a test to ensure it stays that way. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
neilalexander
added a commit
that referenced
this pull request
Sep 8, 2025
Includes the following: - #7200 - #7201 - #7202 - #7209 - #7210 - #7211 - #7213 - #7212 - #7216 - #7217 - #7230 - #7239 - #7246 - #7248 - 8241a15, specifically delayed errors that are not JS API errors - #7158 (not containing 2.12-specific changes) - #7233 - #7255 - #7249 - #7259 - #7265 - #7273 (not including Go 1.25.x) - #7258 - #7222 Signed-off-by: Maurice van Veen <github@mauricevanveen.com> Signed-off-by: Neil Twigg <neil@nats.io>
neilalexander
added a commit
that referenced
this pull request
Oct 13, 2025
Follow-up of a small bug introduced in #7209 that could result in desync under niche conditions. If a follower is behind it will request catchup from the leader. The leader however could send more catchup data than the follower requested by sending it up to the last known entry. The follower will then mark catchup as finished when it has received what it knew to be all entries, but it may receive more messages from the leader still. If multiple catchups were running in parallel, this could result in the follower marking the catchup as complete but then still letting an append entry from another catchup through that could truncate the WAL for entries that were already responded to as "can be committed". This PR simply adds a small guard to not allow truncation from a catchup entry if catchup has completed. Later on we'll need to look at how to improve catchup in general, especially with fast batch ingest that will require Raft catchup to be faster than that as well. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
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.
A follower could be running catchup and then receive "new" very delayed entries from an old leader. This would result in one entry being allowed through to truncate or reset the WAL, while subsequent old entries would be rejected. This would result in desync if the current leader had already committed the entry at that index.
Signed-off-by: Maurice van Veen github@mauricevanveen.com