Skip to content

Commit

Permalink
Run Stop calls in parallel, to mitigate blocking behaviour of `Stop…
Browse files Browse the repository at this point in the history
…` introduced in prometheus/prometheus@086be26 when draining is enabled
  • Loading branch information
charleskorn committed Jun 14, 2024
1 parent ad55070 commit aa9f31b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/ruler/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,19 @@ func (r *DefaultMultiTenantManager) Stop() {

// Stop notifiers after all rule evaluations have finished, so that we have
// a chance to send any notifications generated while shutting down.
level.Info(r.logger).Log("msg", "stopping user notifiers")
wg = sync.WaitGroup{}
r.notifiersMtx.Lock()
for _, n := range r.notifiers {
n.stop()
wg.Add(1)
go func(n *rulerNotifier) {
defer wg.Done()
n.stop()
}(n)
}
wg.Wait()
r.notifiersMtx.Unlock()
level.Info(r.logger).Log("msg", "all user notifiers stopped")

// cleanup user rules directories
r.mapper.cleanup()
Expand Down

0 comments on commit aa9f31b

Please sign in to comment.