mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-04 12:01:06 +02:00
Move m.targetsMtx.Lock down into the loop
Make sure the order of locks is always the same in all functions. In ApplyConfig() we have m.targetsMtx.Lock() after provider is locked, so replicate the same in allGroups(). Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
This commit is contained in:
parent
7d55ee8cc8
commit
59761f631b
@ -413,9 +413,9 @@ func (m *Manager) allGroups() map[string][]*targetgroup.Group {
|
||||
n := map[string]int{}
|
||||
|
||||
m.mtx.RLock()
|
||||
m.targetsMtx.Lock()
|
||||
for _, p := range m.providers {
|
||||
p.mu.RLock()
|
||||
m.targetsMtx.Lock()
|
||||
for s := range p.subs {
|
||||
// Send empty lists for subs without any targets to make sure old stale targets are dropped by consumers.
|
||||
// See: https://github.com/prometheus/prometheus/issues/12858 for details.
|
||||
@ -430,9 +430,9 @@ func (m *Manager) allGroups() map[string][]*targetgroup.Group {
|
||||
}
|
||||
}
|
||||
}
|
||||
m.targetsMtx.Unlock()
|
||||
p.mu.RUnlock()
|
||||
}
|
||||
m.targetsMtx.Unlock()
|
||||
m.mtx.RUnlock()
|
||||
|
||||
for setName, v := range n {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user