D3D12-PIPELINE-CACHE-CONCURRENT-PUBLISH: tolerate Windows AccessDenied on concurrent cache publish #2674
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2674"
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?
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-30T01:43:37Z.
Claimed in #2570 as
D3D12-PIPELINE-CACHE-CONCURRENT-PUBLISH(#issuecomment-7261030254).What and why
In
d3d12/crates/leonida-pipeline/src/cache.rs,get_or_convert()stages a converted asset into a temporary file and publishes it viastd::fs::rename(&tmp, &path). On Windows, when another thread/process concurrently publishes or holds&pathopen withoutFILE_SHARE_DELETE,std::fs::renamefails withERROR_ACCESS_DENIED(os error 5/ErrorKind::PermissionDenied). Currentlyget_or_convert()removes&tmpand propagates that error even though&pathis already published on disk.This change cleans up
&tmpand returnsOk(path)wheneverstd::fs::rename(&tmp, &path)fails andpath.is_file()is already true (a peer won the race), while continuing to propagate errors when&pathis not present as a file on disk.Verification (Red -> Green)
Hardware / OS: native Windows 11 Pro (
10.0.26200), AMD Ryzen 7 7800X3D, Rust1.98.concurrent_publish_while_reader_holds_destination_succeeds_and_cleans_stagingfailed withOs { code: 5, kind: PermissionDenied, message: "Access is denied." }.main40e7fe69d):cargo test -p leonida-pipeline --lib—8 passed; 0 failed.python -I scripts/check_no_game_data.py d3d12/crates/leonida-pipeline/src/cache.rs— PASS.AI-assisted: Antigravity (Gemini 4 Neon)
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T01:49:12Z.
Independent Windows cache publication test. I used
59399dad8on40e7fe69d(clean merge tree113838f6c), Windows 11 build 26300 with MSVC and Rust 1.98.1. All eight tests on the exact PR tree passed.I added a local probe with eight real writer threads per round. All eight first miss the key. One publishes, and a reader opens that hit with
FILE_SHARE_READonly before seven waiting writers resume. Across ten rounds, main returned Windows error 5 to all 70 followers. The PR returned the published path to all 70 followers. Both arms left the expected bytes and exactly one file in the shard directory. The PR probe plus its existing suite passed 9/9. Synthetic temporary files, CPU only.One diff/description mismatch: the recovery guard currently accepts any rename error when
path.is_file()is true. The PR description namesPermissionDeniedandAlreadyExists. The probe verifies the error-5 case.AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-30T01:54:06Z.
Thanks for the independent 8-writer probe and for catching the description mismatch, @ecox982745! Updated the PR description to accurately reflect that the guard recovers on any rename error when
path.is_file()is already true (keeping the verified commit59399dad8unchanged).AI-assisted: Antigravity (Gemini 4 Neon)
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T17:14:15Z.
Cross-process publication and retry on the current head
MEASURED. I tested
be2a1ab0fonmain1d4949d58(merge tree527f01df2). Rust 1.98.1,x86_64-pc-windows-msvcvia cargo-xwin, Wine 11.22 on CachyOS. The fixture starts two independent Windows writer processes and waits for both to enter the converter after missing the same cache key. The first publishes throughCache::get_or_convert. The controller opens its output withFILE_SHARE_READbefore releasing the second process.mainThe open reader saw the expected 32,768 bytes before and after the second writer's attempt. The cache shard contained exactly one entry after every publish attempt and retry. In the directory case the failed attempt left only the directory entry, and retry after removing it left just the expected file. A further lookup reused that file without calling the converter again. Stock
leonida-pipeline --libtests passed 7 onmainand 8 on the PR.Scope: synthetic temporary files and Windows file-sharing semantics under Wine. AI-assisted: Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T18:00:31Z.
RUN - native Windows red/green (Verified by OreoFR) - Intel Core Ultra 7 155H, Windows 11 Pro 10.0.26300, CPU only.
afb511541; green = main + this PR atbe2a1ab0f(git merge --no-ff, clean, merge tree7b88c0b8d).cache.rstaken from the PR with only the fix hunk (thematchonstd::fs::rename) put back to main's one-linerename; the new test is kept as is.rustc 1.98.1 (48a229cea 2026-09-01),x86_64-pc-windows-msvc, pinned byd3d12/rust-toolchain.toml. Native Windows, not Wine.d3d12/, one worktree and onetarget/per arm):cargo test -p leonida-pipelineResult: PASS
afb511541concurrent_publish_while_reader_holds_destination_succeeds_and_cleans_stagingpanics atcache.rs:287onunwrap()withos error 5(access denied): the rename over a destination held open withFILE_SHARE_READonly is refused.RACE, and leaves exactly one file in the shard directory, with no.tmp-*left over. The 7 existing tests pass on all three arms. There are 0 doc-tests.Not covered:
path.is_file()is true for a reason other than a racing publisher. The guard accepts any rename error in that case, as the updated description says.This run was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T18:10:37Z.
Native Windows cross-process verification. I checked
be2a1ab0fmerged withad36782c6(treeabdf3818b), on Windows 11 build 26300 with Rust 1.98.1 MSVC release. This complements the Wine process check and the native single-process regression above.Two separate publisher processes entered the converter after missing the same key. Each case ran 12 times per tree.
FILE_SHARE_READonlyThe published output always matched all 32,768 expected bytes. In the directory case the shard contained just the directory after the failed attempt. In all cases it contained just the published file after success, and the next lookup returned it without converting again. Stock library tests passed 7/7 on the base and 8/8 with the PR. Synthetic file I/O only. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T19:14:08Z.
RUN · VERIFY-2674-RTX4060 · by MoonEyes (another person than the author) on head
be2a1ab0f, with #2674 (be2a1ab0f) and #2656 (02de3303a) merged intomain8f41d7d01. Windows 11 Pro 26300, RTX 4060 8 GB,-SeriesS -FrameGen 2, diag build.cargo test -p leonida-pipeline --locked: 8 passed;cargo test -p leonida --locked: 46 passed; 0 failed.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T19:19:57Z.
Merging. Head
be2a1ab0fmerges cleanly withmain8f41d7d01and does not force a rebase of #2566. Run in the game of 450 s steady (RTX 4060, with both pull requests, no device loss) on this head; cargo tests green; checked by two other people. Merged by MoonEyes.AI-assisted (Claude Code).