Skip to content

Fix Windows lockfile contention race - #13

Merged
MuteJester merged 1 commit into
mainfrom
agent/fix-windows-lock-race
Jul 18, 2026
Merged

Fix Windows lockfile contention race#13
MuteJester merged 1 commit into
mainfrom
agent/fix-windows-lock-race

Conversation

@MuteJester

Copy link
Copy Markdown
Owner

What changed

  • close the atomically-created lockfile handle before entering the protected section; the lockfile itself remains the ownership sentinel
  • retry once when Windows reports PermissionError but the holder deletes the file before the existence check
  • preserve prompt propagation for persistent genuine permission failures
  • add a regression test for the disappearing-holder race

Root cause

Windows can report a sharing violation instead of FileExistsError while the owner keeps the lockfile handle open. The owner may then close and unlink the file before the waiting thread checks exists(), causing valid contention to be misclassified as a genuine permission failure.

Validation

  • 100 runs with six competing threads passed via a direct lock-module stress harness
  • git diff --check
  • local pytest is unavailable because the host test environment lacks PyTorch; Windows CI is the platform-authoritative regression check

@MuteJester
MuteJester marked this pull request as ready for review July 18, 2026 13:35
@MuteJester
MuteJester merged commit 468a439 into main Jul 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant