Pipeline: Cache::get_or_convert fails on Windows concurrent publication race #890
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#890
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@davi713albano-coder on GitHub · 2026-11-24 13:33 UTC · original
What's wrong
In
crates/victory-pipeline/src/cache.rs,Cache::get_or_convertwrites to a staging file.tmp-<pid>-<n>and publishes it viastd::fs::rename(&tmp, &path). Whenrenamefails, it removes&tmpand unconditionally returns the error.On Windows, if two worker threads (or two processes) convert the same content-addressed key concurrently and the winner's published file is opened for reading before the loser's
std::fs::rename(&tmp, &path)runs, Windows rejectsMoveFileExWwith a sharing/access violation even thoughpathis now a valid published file for that exact immutable BLAKE3 key.Fix
Separate
file.write_allerror handling fromstd::fs::renameerror handling:write_allfails, remove&tmpand return the error.renamefails, remove&tmp; ifpath.is_file()is now true (another worker won the race to publish this content-addressed entry), returnOk(path). Whenpathis not a file (e.g., an obstructing directory as infailed_publication_removes_the_staging_file), the error is still propagated.Because external PR creation is restricted (
collaborators_only), the CI-green branch is ready on my fork:32e7e81(based onmainffe310e,crates/victory-pipeline/src/cache.rs+111/-3)Tests & Verification
Added 2 unit tests in
victory-pipeline:concurrent_publication_reuses_existing_entry_and_removes_staging(simulates a concurrent writer publishingtargetand holding it open on Windows withFILE_SHARE_READonly sorenamedeterministically fails; verifiesOk(target)is returned and the staging file is cleaned up)concurrent_threads_converting_same_key_all_succeed(8 barrier-synchronized threads callingget_or_converton the same key and reading the output immediately; verifies all succeed and no.tmp-*files remain)Verified on GitHub Actions (
windows-latest) using upstreamci.yml(cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features, andcargo test --workspace --lockedincludingxtaskasset-policy check):victory-pipeline: 6 passed, 0 failed (full workspace: 344 passed, 0 failed, 6 ignored)No game data used. AI-assisted.
@DaniiL35 on GitHub · 2026-11-24 13:42 UTC · original
Verified branch
32e7e81(on top offfe310e):Concurrency & Correctness Analysis
std::fs::renamedelegates toMoveFileExW(..., MOVEFILE_REPLACE_EXISTING). When multiple worker threads convert the same key concurrently, the winner successfully renames its.tmpfile topath. If a consumer or another thread openspath(default Windows sharing withoutFILE_SHARE_DELETE), concurrent losers attempting to rename their own staging files overpathreceiveERROR_SHARING_VIOLATION/ERROR_ACCESS_DENIED. The unpatched code treated this as a hard error.converter.id(),converter.version(),input), an entry atpathis guaranteed to be bit-for-bit identical to what the losing worker produced.pathvia atomic rename from completed staging files, an existing file atpathis guaranteed to be fully written and not a partial write.renamefails due to a directory collision (as infailed_publication_removes_the_staging_file),path.is_file()isfalseand the error is correctly returned.writtenfailure andrenamefailure), the temporary staging file is guaranteed to be removed, preventing orphan.tmp-*files from accumulating in the cache hierarchy.Test Coverage
concurrent_publication_reuses_existing_entry_and_removes_staging: Deterministically exercises the Windows sharing violation by holdingtargetopen withshare_mode(1)(FILE_SHARE_READwithoutFILE_SHARE_DELETE). Verified that the winner's file is preserved, the loser's staging file is cleaned up, andOk(target)is returned.concurrent_threads_converting_same_key_all_succeed: 8 barrier-synchronized threads racing on the same key all succeed, andread_dirverifies exactly 1 file remains in the bucket directory.#[cfg(windows)]gating onOpenOptionsExtcorrectly keeps the test suite portable and warning-free across non-Windows targets.Policy & Toolchain
Upper,Racing) with synthetic text byte slices.cargo xtask policy: clean.main(ffe310e).Reviewed and verified. AI-assisted with Antigravity.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 13:45 UTC · original
I checked the same-key race with two independent processes on native Windows 10. The first process paused inside its converter. The second published the entry and held it open with
FILE_SHARE_READwhile the first tried to publish.At
ffe310e, the first process received the Windows access/sharing error in all 10 rounds. With the candidate, both processes succeeded in all 10 rounds. Every round ended with one readable cache entry containing the expected bytes and zero staging files. All sixvictory-pipelinelibrary tests passed on the candidate. Tested commit32e7e81AI-assisted. Verified with synthetic bytes in temporary caches.
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 13:51 UTC · original
Verified and merged downstream in PR #26. Passing unit tests concurrent_publication_reuses_existing_entry_and_removes_staging and concurrent_threads_converting_same_key_all_succeed pass cleanly under Windows 11.
@oddmaniv on GitHub · 2026-11-24 20:11 UTC · original
Independent integration coverage for this cache race is available in https://github.com/oddmaniv/VIctory/pull/2 (commit
b9ae66521be52a7cfebbdfd3eff3272b684a5419), combining the existing fixes from #1109 (DocBlack89, published by divyeshganta) and #1324 (mgunes1311-lab).The new synthetic Windows regression forces both a stale staging-name collision and a published destination held open without delete sharing in the same
get_or_convertcall. It runs in an isolated test process, with no production reset hook. With the same test, main fails with Windows error 80, #1109 alone fails with error 5, and #1324 alone fails with error 80; the combined implementation passes. It also checks the published bytes, preservation of the stale file, and cleanup of the current writer's staging file.On Windows with Rust 1.98.1, the pipeline suite passes all 9 tests; both workspace Clippy variants, changed-file formatting and asset policy pass. The unfiltered workspace run is 346 passed, 1 failed, 6 ignored; the same display-deferrals assertion also fails on the base revision (341/1/6).
This is integration/regression evidence, not a replacement for the existing PRs or a claim of gameplay improvement. The new test can be adapted into whichever implementation lands. Synthetic inputs only; AI-assisted.
@Marvisak on GitHub · 2026-11-25 06:59 UTC · original
Automated triage for the maintainers.
Confirmed on
main:Cache::get_or_convertincrates/victory-pipeline/src/cache.rsreturns therenameerror whenever publishing the staging file fails, even when another worker has just published the same content-addressed entry; the comments reproduce the Windows sharing error with two processes. Open PR #1324 (mgunes1311-lab) carries the same fix (accept the existing entry). Pull requests are open to everyone, so if your branch differs, please compare with #1324 and comment there or open your own.Generated by Claude Code