Skip to content

Retry transient Windows atomic file replacements - #10

Merged
EvolutionUnleashed merged 1 commit into
mainfrom
codex/windows-atomic-replace-retry
Sep 11, 2026
Merged

EvolutionUnleashed merged 1 commit into
mainfrom
codex/windows-atomic-replace-retry

Conversation

@EvolutionUnleashed

@EvolutionUnleashed EvolutionUnleashed commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Atomic state publication can fail on Windows when a reader briefly holds the destination. Retry native Windows errors 5 and 32 at the replacement step, using the same completed temporary file. The first attempt stays immediate; at most six retries request 0.63 seconds of sleep per replacement. Exhausted failures still propagate through existing cleanup and caller handling.

The change applies to atomic text and byte writes. It preserves locking, preflight, write guards, fsync, immutable publication and existing generated-view warning behavior. Independent adversarial reviewers agreed on the demonstrated failure mechanism and repair before implementation. The original CI log does not identify the process that held the file.

Validation:

  • Two real Windows handle-contention regressions fail against the unchanged baseline and pass with the repair. Nine new tests cover recovery, persistent failures, exact bytes, cleanup, error classification, retry bounds and the CLI's nonzero state-write failure.
  • Complete local Windows suites on Python 3.8.10 and 3.12.10: 282 passed, 12 skipped, zero failures/errors each. Both include the original 24-process startup test and all nine new regressions.
  • Canonical benchmark gates pass on both runtimes; source compilation and whitespace checks pass.
  • The 12 skips include unavailable Windows privileges/platform facilities and one pre-existing archive/symlink setup collision, independently reproduced on the unchanged baseline. They are not counted as passes.
  • An initial local Git ownership prerequisite failure was independently reproduced and corrected only in the test process environment; no test assertions were weakened.

GitHub Actions run #35 passed on its first attempt for head 1f932a725052fb1fe9a205bf141d770f33c47800. All four jobs passed compilation, unit tests and canonical benchmark gates:

Runner Actual Python Passed Skipped Failures/errors
Ubuntu 3.8.18 287 7 0
Ubuntu 3.12.14 287 7 0
Windows 3.8.10 288 6 0
Windows 3.12.10 288 6 0

Each job discovered 294 tests. Both Windows jobs passed all nine new regressions; Linux passed the four portable cases and skipped the five native Windows cases. The original 24-process startup test and historical-version waiter passed in all four jobs. Skips are not passes: each job still skips the pre-existing archive-path setup collision, alongside its listed platform/privilege exclusions.

GitHub tested merge commit a22cb5f44d60815ee543cd7358bec6ccd65d842a; its tree was independently verified identical to the reviewed head tree. The actual PR remains unmerged.

@EvolutionUnleashed
EvolutionUnleashed merged commit 1f932a7 into main Sep 11, 2026
4 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