[FIXED] NRG: Always only report leader after noop-entry#7460
Merged
neilalexander merged 1 commit intomainfrom Oct 28, 2025
Merged
[FIXED] NRG: Always only report leader after noop-entry#7460neilalexander merged 1 commit intomainfrom
neilalexander merged 1 commit intomainfrom
Conversation
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
| // Wait for this message (and potentially more) to be applied. | ||
| // It's important to wait signaling we're leader if we're not up-to-date yet, as that | ||
| // would mean we're in a consistent state compared with the previous leader. | ||
| n.sendPeerState() |
Member
There was a problem hiding this comment.
We probably only want this to happen if n.switchState() returns success?
Member
Author
There was a problem hiding this comment.
I don't think this is necessary. We only call n.switchToLeader if we previously ran as candidate and won the vote. That means n.switchState(Leader) will always return true. Not sure why I added the if leadChange before.
neilalexander
added a commit
that referenced
this pull request
Oct 30, 2025
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.
This PR fixes an issue where leadership reporting would be a little too soon. It would wait for all entries in the current log to be committed and applied, but it would not wait for the NOOP-entry to be applied. This is no issue per se for meta/streams/consumers/ normally, but it becomes an issue when using atomic batching in 2.12 since these could span multiple append entries.
If an atomic batch is only partially proposed in separate append entries (so it will not commit), this batch will always be rejected properly. But, because we don't wait for the apply of the NOOP-entry (in our case the peerstate) this means leadership is signaled before the batch is rejected. This results in subscribing to the stream subjects and possibly receiving new messages before we apply the peerstate. Which initializes the
mset.clseqwith the correct value, but using the wrongmset.clfsvalue. The batch is then not accounted for in themset.clfsyet, which could then result in one atomic batch to be only partially committed.Even though this fix only affects atomic batching in 2.12, it's still a fix that can be backported to 2.11.
Signed-off-by: Maurice van Veen github@mauricevanveen.com