[FIXED] NRG: Fix server shutdown race condition#7045
Merged
neilalexander merged 1 commit intomainfrom Jul 8, 2025
Merged
Conversation
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
neilalexander
added a commit
that referenced
this pull request
Jul 25, 2025
Includes the following: - #7031 - #7033 - #7034 - #7035 - #7036 - #7040 - #7043 - #7045 - #7047 - #7046 - #7050 - #7051 - #7052 - #7053 - #7061 - #7063 - #7064 - #7065 - #7066 - #7070 - #7072 - #7080 - #7026 - #6728 - #7074 - #7089 - #7095 - #7087 - #7094 - #7096 - #7099 Signed-off-by: Neil Twigg <neil@nats.io>
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.
The
for s.isRunning() {..}makes sure the Raft run loop keeps running while the server is running and stops when it's done. Although this sounds sane, this actually results in a race condition. If then.State()changes, for example if you're leader and do a leader transfer as part of shutting down, then this race condition could hit wheres.isRunning()breaks us out of the loop, and then themonitorCluster/Stream/Consumercan't install a snapshot on shutdown.The run loop can simply be a
for {..}, because the last part of shutting down the server iss.shutdownRaftNodes()which stops any nodes that weren't stopped already. Which would properly break the loop.Signed-off-by: Maurice van Veen github@mauricevanveen.com