Problem
The ingestor can panic with send on closed channel on SIGTERM if an MQTT watchdog force-reconnect is in flight during shutdown.
Where
cmd/ingestor/mqtt_watchdog.go, in the force-reconnect path of the stall watchdog. The watchdog runs ForceReconnectFn in a goroutine and then calls emit(...) ("WATCHDOG reconnect attempt issued"). If shutdown closes the channel behind emit while that goroutine is still inside ForceReconnectFn, the later send panics.
Background
Suggested fix
- Make the emit path shutdown-safe. For example:
- use a context or done channel and
select on it instead of sending to a possibly closed channel;
- or stop and wait for in-flight force-reconnect goroutines before closing the channel.
- Add a test that triggers a force-reconnect whose
ForceReconnectFn blocks, shuts the watchdog down, then unblocks it. The test should assert no panic, and run under -race.
No behaviour change for normal operation is expected.
Problem
The ingestor can panic with
send on closed channelon SIGTERM if an MQTT watchdog force-reconnect is in flight during shutdown.Where
cmd/ingestor/mqtt_watchdog.go, in the force-reconnect path of the stall watchdog. The watchdog runsForceReconnectFnin a goroutine and then callsemit(...)("WATCHDOG reconnect attempt issued"). If shutdown closes the channel behindemitwhile that goroutine is still insideForceReconnectFn, the later send panics.Background
Suggested fix
selecton it instead of sending to a possibly closed channel;ForceReconnectFnblocks, shuts the watchdog down, then unblocks it. The test should assert no panic, and run under-race.No behaviour change for normal operation is expected.