Skip to content

Pipeline: accept existing entry when concurrent cache publication races on Windows - #1324

Merged
Marvisak merged 4 commits into
Marvisak:mainfrom
mgunes1311-lab:pipeline-cache-concurrent-publish
Nov 25, 2026
Merged

Marvisak merged 4 commits into
Marvisak:mainfrom
mgunes1311-lab:pipeline-cache-concurrent-publish

Conversation

@mgunes1311-lab

Copy link
Copy Markdown
Contributor

On Windows, std::fs::rename(&tmp, &path) fails with access denied / sharing violation if another thread or process concurrently finishes publishing the same content-addressed CacheKey entry and holds an open read handle on path after the path.is_file() check at line 51.

Changes

  • Handle write errors before std::fs::rename separately in Cache::get_or_convert (crates/victory-pipeline/src/cache.rs).
  • If std::fs::rename(&tmp, &path) fails, remove the staging file and return Ok(path) when path.is_file() is now true (still propagating the error when path is not a file, e.g. a directory).
  • Added synthetic unit test accepts_entry_published_concurrently_while_open.

Verification

  • cargo test -p victory-pipeline --target x86_64-pc-windows-msvc --locked (5 passed; 0 failed)
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --locked
  • cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged (asset policy: 1 files ok)

Keep the published entry open without delete sharing and assert that replacement is blocked. The regression fails with the pre-fix publication code and passes with the current implementation.

Validation: 5 pipeline tests passed on x86_64-pc-windows-msvc; pipeline Clippy with warnings denied and formatting checks passed.
@acetonahard-code

Copy link
Copy Markdown

Tested on Windows 11 with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-pipeline passed failed ignored
main 4 0 0
main + this PR 5 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Update after your rebase: Cache::get_or_convert (crates/victory-pipeline/src/cache.rs) now returns the existing entry when the rename fails and another writer has already published that key. That is correct because entries are content-addressed and every writer publishes by write-then-rename, so an existing file is always complete. A failed write still removes the staging file and returns the error. When the target is not a file (as in failed_publication_removes_the_staging_file), the rename error is still returned. The Windows test accepts_entry_published_concurrently_while_open now uses the (PathBuf, File) return of tempfile_in correctly: it holds the entry open with FILE_SHARE_READ, confirms that a rename over it fails, and checks that only the published entry is left in the directory. It merges cleanly with main (940d32f).

CI: passing (check).


Generated by Claude Code

@mgunes1311-lab

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (940d32f), adapted accepts_entry_published_concurrently_while_open to tempfile_in's (PathBuf, File) return signature while keeping the path.is_file() fallback after rename, and verified cargo test -p victory-pipeline --locked (8/8 passed) + clippy locally.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
nazmi added a commit to nazmi/VIctory that referenced this pull request Nov 25, 2026
Adapt PR Marvisak#1324 at 8f28c35 (including a8ed29d) by mgunes1311-lab. Preserve the local existing-writer fallback and collision-resistant staging. Return staging-write errors separately from rename errors and strengthen the existing held-reader regression to prove replacement is blocked, instead of adding a duplicate race test. Exact source five tests and candidate nine tests pass; removing the rename fallback fails the existing regression. Deterministic staging-write failure injection was not available.

Co-authored-by: mgunes1311-lab <mgunes.1311@gmail.com>
nazmi added a commit to nazmi/VIctory that referenced this pull request Nov 25, 2026
Marvisak#1324, Marvisak#1432 and Marvisak#1032 landed with their evidence; Marvisak#1436 is closed upstream.
The two accepted ztrx ports were re-verified as working (wait-budget tests and
the launcher parse), and a declaration sweep shows 575 ztrx-only symbols, which
is why the remaining features stay held rather than cherry-picked.
@Marvisak
Marvisak merged commit a73d59e into Marvisak:main Nov 25, 2026
1 check passed
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
notquiteog pushed a commit to notquiteog/victory-nvidia that referenced this pull request Nov 26, 2026
…es on Windows (Marvisak#1324)

* Pipeline: accept existing entry when concurrent cache publication races on Windows

* Pipeline: exercise the blocked Windows cache publication path

Keep the published entry open without delete sharing and assert that replacement is blocked. The regression fails with the pre-fix publication code and passes with the current implementation.

Validation: 5 pipeline tests passed on x86_64-pc-windows-msvc; pipeline Clippy with warnings denied and formatting checks passed.

* Pipeline: adapt concurrent publication test to new tempfile_in signature

(cherry picked from commit a73d59e)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants