Skip to content

Commit

Permalink
Cancel pending checkForOrphans on cluster monitor exit
Browse files Browse the repository at this point in the history
This was leaving dangling goroutines and creating confusing logging in unit test runs.

Signed-off-by: Neil Twigg <[email protected]>
  • Loading branch information
neilalexander authored and wallyqs committed Aug 9, 2024
1 parent 6815671 commit 6f953c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,11 @@ func (js *jetStream) monitorCluster() {
updateConsumers: make(map[string]*consumerAssignment),
}

// Make sure to cancel any pending checkForOrphans calls if the
// monitor goroutine exits.
var oc *time.Timer
defer stopAndClearTimer(&oc)

for {
select {
case <-s.quitCh:
Expand Down Expand Up @@ -1375,7 +1380,7 @@ func (js *jetStream) monitorCluster() {
// Clear.
ru = nil
s.Debugf("Recovered JetStream cluster metadata")
time.AfterFunc(30*time.Second, js.checkForOrphans)
oc = time.AfterFunc(30*time.Second, js.checkForOrphans)
// Do a health check here as well.
go checkHealth()
continue
Expand Down

0 comments on commit 6f953c7

Please sign in to comment.