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

Manually merged
github merged 4 commits from gh-pr/1324/head into gh-pr/1324/base 2026-11-26 04:27:34 +00:00
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-24 17:26 UTC · original
mgunes1311-lab:pipeline-cache-concurrent-publish → main · +65 −3 · 1 files · 4 commits · merged 2026-11-25 21:50 UTC

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)
**@⁠mgunes1311-lab** on GitHub · 2026-11-24 17:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1324) `mgunes1311-lab:pipeline-cache-concurrent-publish` → `main` · +65 −3 · 1 files · 4 commits · merged 2026-11-25 21:50 UTC 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:33 +00:00
github manually merged commit ba36bfbf85 into gh-pr/1324/base 2026-11-26 04:27:34 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 21:04 UTC · original

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.

**@⁠acetonahard-code** on GitHub · 2026-11-24 21:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7144450138) 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. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:35 UTC · original · edited 2026-11-25 07:21 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 02:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7150922129) · edited 2026-11-25 07:21 UTC <!-- victory-triage v1 head=ba36bfbf85c52b3bbb248bd319d7e116c8bdc047 verdict=merge-candidate at=2026-11-25T07:21:32Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-25 04:52 UTC · original

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.

**@⁠mgunes1311-lab** on GitHub · 2026-11-25 04:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7153249589) 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.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1324
No description provided.