Repository navigation
fix(runregistry): retry record removal on Windows sharing violations - #5089
Merged
trungutt merged 1 commit intoDec 1, 2026
Merged
Conversation
On Windows, DeleteFile fails while any handle on the record is open without FILE_SHARE_DELETE: a concurrent List (os.ReadFile) or an AV scanner. The cleanup tried once and ignored the error, and List never prunes a record whose pid is still alive, so the record stayed until the process exited. This is what TestStartSessionCoordinatorListenUsesIsolatedRegistry keeps hitting on the Windows runner: the test polls List while the cleanup runs. Widening its wait to 30s (e10d488) could not help, since the removal is never retried. Retry transient removal failures with a bounded backoff. Signed-off-by: Trung Nguyen <trung.nguyen@docker.com>
trungutt
marked this pull request as ready for review
December 1, 2026 15:10
aheritier
approved these changes
Dec 1, 2026
aheritier
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, no issues. Thanks for adding a Windows regression test that holds the file open during cleanup.
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.
TestStartSessionCoordinatorListenUsesIsolatedRegistrykeeps failing on the Windows runner with "cancelling the run must remove the discovery record", even on PRs that don't touch this code (e.g. #5088).The problem
When a run with a control plane shuts down, it deletes a small record file that tells other tools "a run is live at this address." That delete is tried only once, and if it fails, nothing notices.
On Linux and macOS, you can delete a file even while someone else is reading it. Windows refuses: if any other program has the file open at that moment, the delete fails. Two things often have the file open:
If the single delete attempt lands at the wrong moment, it fails silently. The record then never goes away, because the cleanup that runs while reading the folder only removes records of processes that have died, and this process is still running. The test waits 30 seconds for something that will never happen, then fails.
The same can happen outside tests: any tool listing runs while one shuts down can leave behind a record pointing at a dead address.
Why the earlier fix didn't work
e10d488 assumed the delete was just slow on Windows and raised the wait from 5 to 30 seconds. But the delete isn't slow, it simply never happens again. Waiting longer changes nothing.
The fix
If the delete fails because the file is busy on Windows, wait a moment and try again. Waits start at 10ms and double each time, up to 250ms, for at most 5 seconds. Reads and scans take milliseconds, so a retry quickly succeeds. If it still fails after 5 seconds, a warning is logged instead of being silently ignored. Linux and macOS behave exactly as before.
The new Windows-only test holds the record file open while the cleanup runs, checks the cleanup keeps waiting instead of giving up, then releases the file and checks the record gets deleted. Without the fix, it fails every time, not just occasionally.