Fix deadlock when Telegraf is aligning aggregators (#5612)

This commit is contained in:
Adrián López 2019-03-20 18:36:51 +01:00 committed by Daniel Nelson
parent 5d9b829776
commit 33ee309fd1
1 changed files with 4 additions and 2 deletions

View File

@ -378,7 +378,10 @@ func (a *Agent) runAggregators(
for _, agg := range a.Config.Aggregators { for _, agg := range a.Config.Aggregators {
wg.Add(1) wg.Add(1)
go func(agg *models.RunningAggregator) { go func(agg *models.RunningAggregator) {
defer wg.Done() defer func() {
wg.Done()
close(aggregations)
}()
if a.Config.Agent.RoundInterval { if a.Config.Agent.RoundInterval {
// Aggregators are aligned to the agent interval regardless of // Aggregators are aligned to the agent interval regardless of
@ -394,7 +397,6 @@ func (a *Agent) runAggregators(
acc := NewAccumulator(agg, aggregations) acc := NewAccumulator(agg, aggregations)
acc.SetPrecision(precision, interval) acc.SetPrecision(precision, interval)
a.push(ctx, agg, acc) a.push(ctx, agg, acc)
close(aggregations)
}(agg) }(agg)
} }