Skip to content

supervisor: Fix leaking logrus Goroutine on spawn failure

For a long time we have observed leaking Goroutines in our supervisor test which verifies that the circuit breaker kicks in in case spawning of the process fails. As it turns out, this is a real issue: we set both stdout and stderr of the new command to an io.PipeWriter created for logging purposes. And because the Go runtime doesn't automatically close these writers for us, we must make sure to do so ourselves. And while we do that in case the command has been spawned successfully, we don't handle the case where spawning has failed and thus don't close it at all here.

Fix this Goroutine leakage by closing the io.PipeWriter in case we fail to start the command.

Changelog: fixed

Fixes #3927 (closed)

Merge request reports