Goroutine leaks for non-existent command
Gitaly can encounter goroutine leaks when spawning commands without caring about its stderr output, such that trying to spawn a non-existent command, or the spawned command is not executable at all.
I found this issue when monitoring a gitaly demo instance locally. I want to replace the git executable from the gitlab docker image to do some tests, but when I replaced the git executable(whose mod is 0644, my mistake), I got many errors and noticed that gitaly goroutines keeps growing. I realized that there may be goroutine leaks and I finally found the puncture by pprof.
It's very straightforward from pprof that command.writeLines
and logrus.(*Entry).writerScanner
leaked. After some digging I found that command package does leak when calling command.New
with a non-existent command and nil stderr.
I will submit a MR trying to fix this later.