Skip to content

Fix clearing O_NONBLOCK on upgrade

Compare
Choose a tag to compare
@lmb lmb released this 25 Jan 09:25
· 8 commits to master since this release

The Go runtime has annoying behaviour around setting and clearing
O_NONBLOCK: exec.Cmd.Start() ends up calling os.File.Fd() for any
file in exec.Cmd.ExtraFiles. os.File.Fd() disables both the use
of the runtime poller for the file and clears O_NONBLOCK from
the underlying open file descriptor.

This can lead to goroutines hanging in a parent process, after at least
one failed upgrade. The bug manifests by goroutines which rely on
either a deadline or interruption via Close() to be unblocked being stuck
in read or accept like syscalls,. As far as I can tell we've not experienced
this problem in production, so it's most likely quite rare.