Repository navigation
Conversation
TestManager_RestoreFromUpload_CleansUpTempFileAfterCompletion polled the job status and then looked for the staged upload straight away. The job is Done once runFromZipPath calls Finish, but the temp file is removed by the cleanup that TriggerRestoreFromUpload defers in its goroutine, so the check could run first and still see the file (seen on the Windows CI). Call Manager.Wait after the job is Done, which returns only once that goroutine, including the deferred cleanup, has finished. Both the success and the failure subtest had the race.
6 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
No issue. This is a flaky test that failed on the Windows job of #1763, a PR that does not touch
internal/restore: https://github.com/perber/leafwiki/actions/runs/40884561713/job/123484693452What changed
TestManager_RestoreFromUpload_CleansUpTempFileAfterCompletioncould fail withexpected upload temp file to be cleaned up, found: [...]. The test change is two lines plus comments, and no production code changes.The test polls
waitForRestoreDoneand then looks for the staged upload straight away. But the job is alreadyDonewhenrunFromZipPathcallsFinish; the temp file is removed afterwards by thedefer cleanup()in the goroutine thatTriggerRestoreFromUploadstarts. If the check runs between the two, it still sees the file.Both the
successand thefailuresubtest had this race. They now callManager.Wait()afterwaitForRestoreDone, which returns only once that goroutine, including the deferred cleanup, has finished. The doc comment ofWaitmentions shutdown, but it waits on the sameWaitGroupthat tracks this goroutine.How I tested it
stageUploadby 200 ms (not committed). Without the fix both subtests fail (successwith the message from CI,failurewith its "even on failure" variant); with the fix they pass.-count=60before and-count=40after the fix) pass.go testpasses for./internal/restoreand./internal/wiki/restore.GOOS=linux go vet,golangci-lintfor the package andscripts/check-private-references.share clean.Checklist
if featurebranches in shared code (rule 1) (test fix, no new behaviour)Behavior-Change:trailer (commit style) (no behaviour change)