afex / hystrix-go

Netflix's Hystrix latency and fault tolerance library, for Go
MIT License
4.24k stars 477 forks source link

metricExchange.Monitor and poolMetrics.Monitor goroutine leak #95

Open foobatman opened 6 years ago

foobatman commented 6 years ago

We are seeing a pattern which indicates a likely goroutine leak. When there are downstream errors and circuit is opened for any given command, then after a while lot of goroutines get created and never closed ( pprof output attached ). A quick glance at the code suggests that they are created for every command's CircuitBreaker. But we ran few test where only single command is used, still the goroutine count created by metricExchange.Monitor and poolMetrics.Monitor seemed to be increasing according to the pprof output.

Test environment:

We ran around 100 RPM, no failure ( i.e. circuit was never opened ), the expectation was that it will have constant number of go-routines created by hystrix-go lib metricExchange.Monitor and poolMetrics.Monitor. But as it can be seen in the output, the number increased.

pprof output before running the test:

Before running test

pprof output after running the test:

After running test