Skip to content

Don't launch a go routine when creating a temporary directory

Siddharth Asthana requested to merge edith007/gitaly:issue_4760 into master

This MR aims to solve the issue #4760

tempdir package is launching a goroutine every time a temporary directory is created. The purpose of the goroutine is to clean up the temporary directory on context cancellation. This doesn't seem very necessary and has the following downsides:

  • On our tests, we look for goroutines that are still runnning after tests. This deletion goroutine is not synchronized with this and can thus cause flakes.
  • If context is canceled, the directory is deleted. If there is still code operating on the directory, that code can fail with unexpected errors rather than returning a context canceled error.

So instead defer the deletion of the directory when it is created.

Edited by Siddharth Asthana

Merge request reports