From b8bb159a4113b1562a921ce5143d2da804dd769e Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Fri, 31 Mar 2017 12:45:28 -0700 Subject: [PATCH] Fix possible deadlock when output cannot write. (#2610) --- CHANGELOG.md | 1 + internal/buffer/buffer.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f90157f7..cf7c31c4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ be deprecated eventually. - [#1827](https://github.com/influxdata/telegraf/issues/1827): Fix Windows Performance Counters multi instance identifier - [#2576](https://github.com/influxdata/telegraf/pull/2576): Add write timeout to Riemann output - [#2596](https://github.com/influxdata/telegraf/pull/2596): fix timestamp parsing on prometheus plugin +- [#2610](https://github.com/influxdata/telegraf/pull/2610): Fix deadlock when output cannot write ## v1.2.1 [2017-02-01] diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index 5e7818ef1..cdc81fed3 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -45,9 +45,11 @@ func (b *Buffer) Add(metrics ...telegraf.Metric) { select { case b.buf <- metrics[i]: default: + b.mu.Lock() MetricsDropped.Incr(1) <-b.buf b.buf <- metrics[i] + b.mu.Unlock() } } }