c86cff02f9
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 |
||
---|---|---|
.. | ||
allocdir | ||
allochealth | ||
allocrunner | ||
allocwatcher | ||
config | ||
consul | ||
devicemanager | ||
dynamicplugins | ||
fingerprint | ||
interfaces | ||
lib | ||
logmon | ||
pluginmanager | ||
servers | ||
state | ||
stats | ||
structs | ||
taskenv | ||
testutil | ||
vaultclient | ||
acl.go | ||
acl_test.go | ||
agent_endpoint.go | ||
agent_endpoint_test.go | ||
alloc_endpoint.go | ||
alloc_endpoint_test.go | ||
alloc_watcher_e2e_test.go | ||
client.go | ||
client_stats_endpoint.go | ||
client_stats_endpoint_test.go | ||
client_test.go | ||
csi_endpoint.go | ||
csi_endpoint_test.go | ||
driver_manager_test.go | ||
enterprise_client_oss.go | ||
fingerprint_manager.go | ||
fingerprint_manager_test.go | ||
fs_endpoint.go | ||
fs_endpoint_test.go | ||
gc.go | ||
gc_test.go | ||
heartbeatstop.go | ||
heartbeatstop_test.go | ||
node_updater.go | ||
rpc.go | ||
rpc_test.go | ||
testing.go | ||
util.go | ||
util_test.go |