Skip to content

testcfg: Try to fix ETXTBSY errors with gitaly-git2go executable

Patrick Steinhardt requested to merge pks-gitaly-git2go-etxtbsy into master

Our build helpers which build commands on the fly as tests require them first build the executable in a shared place and then copy them into the per-test binary directory. In our CI, we have occasionally seen errors when trying to execute the resulting binaries though, where execution always fails with ETXTBSY. This error happens when trying to exec into an executable that's been concurrently modified. This is quite a curious failure mode: we only ever build commands once due to using sync.Once, and the copied file is also closed before returning. So in theory, there shouldn't be anything that's still modifying the file.

While digging a bit I stumbled over 1 by chance: as it turns out, there used to be an issue with Docker where executing a file that's just been chmod'ed will cause ETXTBSY. And that's exactly what we're doing: we copy binaries into place and chmod them afterwards such that they're executable. The root cause of this seems to be an issue with the overlay filesystem in use, which handled this inconsistently from how it's handled with a "normal" filesystem.

Let's try to fix the bug by not using chmod, but instead creating the file with correct mode directly. Furthermore, just to be sure, we also sync the file to disk.

Fixes #3869 (closed)

Merge request reports