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

Merged
mgunes1311-lab merged 4 commits from upstream-pr/1324 into main 2026-11-25 21:50:36 +00:00
mgunes1311-lab commented 2026-11-24 17:26:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-24T17:26:18Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6587575833 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1324). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-24T17:26:18Z. --- 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`)
acetonahard-code commented 2026-11-24 21:28:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T21:04:56Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144450138 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7144450138). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T21:04:56Z. --- 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>
Marvisak commented 2026-11-25 03:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:35:31Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150922129 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7150922129). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:35:31Z. --- <!-- 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)_
mgunes1311-lab commented 2026-11-25 05:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-25T04:52:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153249589 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1324#issuecomment-7153249589). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-25T04:52:55Z. --- 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.
upstream-sync closed this pull request 2026-11-25 22:02:55 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1324
No description provided.