C#: store replace on Windows tries POSIX-semantics rename first (store-windows-cs) #152
Loading…
Reference in a new issue
No description provided.
Delete branch "store-replace/windows-cs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
StoreReplace.Replace(staged, destination)in GameCult.Caching owns how a staged file becomes the store, for the single-file store (WriteSnapshotAtomically) and the directory store (DirectoryMessagePackBackingStore). On Windows it tries a POSIX-semantics rename first (CreateFileW + SetFileInformationByHandle FileRenameInfoEx, REPLACE_IF_EXISTS|POSIX_SEMANTICS), falls back to MoveFileExW(0x9) on Win32 codes 1/50/87 for the rest of the call, retries 25 x 20 ms on 5/32/33, and throws IOException naming the code otherwise. Other OSes keep File.Replace/File.Move. Port of cultcache-tsreplaceStoreFile.Deleted: the File.Exists/Replace/Move branch in WriteSnapshotAtomically and the directory store's own 3-attempt File.Replace loop.
ACacheOpeningDuringMeshWritesNeverSeesAnEmptyStoreis un-ignored on Windows and tolerates a brief not-found there (still zero empty stores elsewhere). Unresolved kernel32 imports: POSIX call -> same fallback as unsupported; MoveFileExW -> portable File.Replace/Move.Why
File.Replace on Windows leaves a moment with nothing at the path for a lock-free reader (1,722 empty stores in 17,313 opens). POSIX-first makes that absence rare, not impossible: a stalled rename was measured leaving the path absent 5-47 ms on Starfire (open operator question
variants:question:posix-rename-absent-window). Rulingvariants:ruling:windows-replace-posix-first.Verification
5eb2f75c); hand mutations of attempts, the 87 fallback code, fallback stickiness, same-attempt fallback, the posix guard and the unresolved-import handling each fail tests.File\.Replace\(in src/GameCult.Caching and src/GameCult.Caching.MessagePack: only StoreReplace's non-Windows branch.Spec
variants:cut_spec:cut-store-windows-cs.r1, reportvariants:cut_report:cut-store-windows-cs.h1.🤖 Generated with Claude Code
Mutation survivor: Contains("32") matched "Win32". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>