mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 07:03:06 -08:00
Fix target manager CPU busyloop caused by bad done-channel handling.
Unfortunately this isn't nicely testable, as it's timing-dependent and one would have to detect a stray goroutine doing a CPU busyloop... Fixes https://github.com/prometheus/prometheus/issues/1114
This commit is contained in:
parent
097d810f37
commit
99e8fff872
|
@ -128,14 +128,14 @@ func (tm *TargetManager) Run() {
|
||||||
|
|
||||||
tgc := make(chan *config.TargetGroup)
|
tgc := make(chan *config.TargetGroup)
|
||||||
// Run the target provider after cleanup of the stale targets is done.
|
// Run the target provider after cleanup of the stale targets is done.
|
||||||
defer func(prov TargetProvider, tgc chan *config.TargetGroup) {
|
defer func(prov TargetProvider, tgc chan<- *config.TargetGroup, done <-chan struct{}) {
|
||||||
go prov.Run(tgc, tm.done)
|
go prov.Run(tgc, done)
|
||||||
}(prov, tgc)
|
}(prov, tgc, tm.done)
|
||||||
|
|
||||||
tgupc := make(chan targetGroupUpdate)
|
tgupc := make(chan targetGroupUpdate)
|
||||||
updates = append(updates, tgupc)
|
updates = append(updates, tgupc)
|
||||||
|
|
||||||
go func(scfg *config.ScrapeConfig) {
|
go func(scfg *config.ScrapeConfig, done <-chan struct{}) {
|
||||||
defer close(tgupc)
|
defer close(tgupc)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -144,11 +144,11 @@ func (tm *TargetManager) Run() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
tgupc <- targetGroupUpdate{tg: tg, scfg: scfg}
|
tgupc <- targetGroupUpdate{tg: tg, scfg: scfg}
|
||||||
case <-tm.done:
|
case <-done:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(scfg)
|
}(scfg, tm.done)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue