Skip to content

Commit 73acd11

Browse files
committed
Do not create a global statsd "previous instance"
this basically reverts #887 at some point we might want to do some special handling of reloading plugins and keeping their state intact, but that will need to be done at a higher level, and in a way that is thread-safe for multiple input plugins of the same type. Unfortunately this is a rather large feature that will not have a quick fix available for it. fixes #1975 fixes #2102
1 parent 491ba10 commit 73acd11

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
will change te default behavior for users who were not specifying these parameters
77
in their config file.
88

9+
- The StatsD plugin will also no longer save it's state on a service reload.
10+
Essentially we have reverted PR [#887](https://github.com/influxdata/telegraf/pull/887).
11+
The reason for this is that saving the state in a global variable is not
12+
thread-safe (see [#1975](https://github.com/influxdata/telegraf/issues/1975) & [#2102](https://github.com/influxdata/telegraf/issues/2102)),
13+
and this creates issues if users want to define multiple instances
14+
of the statsd plugin. Saving state on reload may be considered in the future,
15+
but this would need to be implemented at a higher level and applied to all
16+
plugins, not just statsd.
17+
918
### Features
1019

1120
- [#2123](https://github.com/influxdata/telegraf/pull/2123): Fix improper calculation of CPU percentages
@@ -52,6 +61,7 @@ in their config file.
5261
- [#1449](https://github.com/influxdata/telegraf/issues/1449): MongoDB plugin always shows 0 replication lag.
5362
- [#1825](https://github.com/influxdata/telegraf/issues/1825): Consul plugin: add check_id as a tag in metrics to avoid overwrites.
5463
- [#1973](https://github.com/influxdata/telegraf/issues/1973): Partial fix: logparser CLF pattern with IPv6 addresses.
64+
- [#1975](https://github.com/influxdata/telegraf/issues/1975) & [#2102](https://github.com/influxdata/telegraf/issues/2102): Fix thread-safety when using multiple instances of the statsd input plugin.
5565

5666
## v1.1.2 [2016-12-12]
5767

plugins/inputs/statsd/statsd.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ var dropwarn = "E! Error: statsd message queue full. " +
3232
"We have dropped %d messages so far. " +
3333
"You may want to increase allowed_pending_messages in the config\n"
3434

35-
var prevInstance *Statsd
36-
3735
type Statsd struct {
3836
// Address & Port to serve from
3937
ServiceAddress string
@@ -244,17 +242,10 @@ func (s *Statsd) Start(_ telegraf.Accumulator) error {
244242
s.done = make(chan struct{})
245243
s.in = make(chan []byte, s.AllowedPendingMessages)
246244

247-
if prevInstance == nil {
248-
s.gauges = make(map[string]cachedgauge)
249-
s.counters = make(map[string]cachedcounter)
250-
s.sets = make(map[string]cachedset)
251-
s.timings = make(map[string]cachedtimings)
252-
} else {
253-
s.gauges = prevInstance.gauges
254-
s.counters = prevInstance.counters
255-
s.sets = prevInstance.sets
256-
s.timings = prevInstance.timings
257-
}
245+
s.gauges = make(map[string]cachedgauge)
246+
s.counters = make(map[string]cachedcounter)
247+
s.sets = make(map[string]cachedset)
248+
s.timings = make(map[string]cachedtimings)
258249

259250
if s.ConvertNames {
260251
log.Printf("I! WARNING statsd: convert_names config option is deprecated," +
@@ -271,7 +262,6 @@ func (s *Statsd) Start(_ telegraf.Accumulator) error {
271262
// Start the line parser
272263
go s.parser()
273264
log.Printf("I! Started the statsd service on %s\n", s.ServiceAddress)
274-
prevInstance = s
275265
return nil
276266
}
277267

0 commit comments

Comments
 (0)