open-nomad/client/logmon
Mahmood Ali c86cff02f9 logmon: Fix a memory leak on task restart
Fix a logmon leak causing high goroutine and memory usage when a task
restarts.

Logmon `FileRotator` buffers the task stdout/stderr streams and
periodically flushing them to log files. Logmon creates a new
FileRotator for each stream for each task run. However, the
`flushPeriodically` goroutine is leaked when a task restarts,
holding a reference to a no-longer-needed `FileRotator` instance
along with its 64kb buffer.

The cause is that the code assumed `time.Ticker.Stop()` closes the
ticker channel, thereby terminating the goroutine, but the documentation
says otherwise:

> Stop turns off a ticker. After Stop, no more ticks will be sent. Stop does not close the channel, to prevent a concurrent goroutine reading from the channel from seeing an erroneous "tick".
https://pkg.go.dev/time#Ticker.Stop
2021-10-05 12:11:53 -04:00
..
logging logmon: Fix a memory leak on task restart 2021-10-05 12:11:53 -04:00
proto update grpc 2020-03-03 08:39:54 -05:00
client.go logmon: add timeout to RPC operations 2019-12-02 10:33:05 -05:00
logmon.go Add gosimple linter (#9590) 2020-12-09 11:05:18 -08:00
logmon_test.go only report tasklogger is running if both stdout and stderr are still running (#8155) 2020-06-12 09:17:35 -04:00
plugin.go Use init to handle plugin invocation 2019-06-13 16:48:01 -04:00
server.go
z_logmon_cmd.go comment on use of init() for plugin handlers 2019-06-18 20:54:55 -04:00