[FIXED] Infinite wait on shutdown of monitor goroutine#7249
Merged
derekcollison merged 1 commit intomainfrom Sep 4, 2025
Merged
[FIXED] Infinite wait on shutdown of monitor goroutine#7249derekcollison merged 1 commit intomainfrom
derekcollison merged 1 commit intomainfrom
Conversation
server/consumer.go
Outdated
| o.closed = true | ||
|
|
||
| // Signal to the monitor loop. | ||
| // Can't use qch here. |
Member
Author
There was a problem hiding this comment.
Maybe we can for the consumer, but not for the stream?
Just copied that over from the stream, that was introduced here: de89207#diff-2f4991438bb868a8587303cde9107f83127e88ad70bd19d5c6a31c238a20c299R4916-R4918
Member
Author
There was a problem hiding this comment.
Turns out we close o.qch as a follower/when stepping down. Shouldn't stop the monitor routine then, so need this other o.mqch channel.
Updated to:
// Signal to the monitor loop.
// Can't use only qch here, since that's used when stepping down as a leader.
server/jetstream_cluster.go
Outdated
| if !isShuttingDown { | ||
| // Signal to the monitor loop. If there's no Raft node, | ||
| // this will be the only way to stop the monitor goroutine. | ||
| mset.mu.Lock() |
Member
There was a problem hiding this comment.
Probably make this a function so as to not keep repeating the code. Compiler will inline.
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
0e9a849 to
5d838c5
Compare
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
Sep 29, 2025
`mset.resetClusteredState` can be the source of many issues due to race conditions. When something has already gone very wrong with replication then it's a good last effort way to try and get us out of this situation. However, we should never be resetting the whole state as a result of a stream snapshot timing out due to no leader or exceeding retries. This PR changes this such that we "just" replay the snapshot and allow us to re-send entries into the apply queue afterward. When running under Antithesis this has shown to resolve many health-related issues such as "node skew" where the Raft node for the stream/consumer assignment is different than what is actually being used for the stream/consumer. Closely related to #7249, this was very likely to be part of the cause of the monitor goroutine not being shutdown. Hypothetically due to the above node skew issue. 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.
This PR fixes an issue where the Raft node is potentially nil for a stream or consumer, resulting in infinite waiting on the
mset/o.monitorWg.Wait()to complete when stopping/deleting the stream/consumer.This is done by introducing the
mqch(monitor quit channel) for the consumer as well. The stream already had this. Also, updates other places to ensure the monitor quit channel is closed prior to callingmonitorWg.Wait().Signed-off-by: Maurice van Veen github@mauricevanveen.com