Pipeline cache: verify content when accepting a racing publication #2826

Open
andrewpozdnakov7-jpg wants to merge 3 commits from upstream-pr/2828 into main
andrewpozdnakov7-jpg commented 2026-11-25 21:35:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T21:35:38Z.


#1324 landed as a73d59e and covers the case where another writer publishes the correct cache entry before Windows rejects the rename. This branch keeps that behavior and checks that the existing file contains the converted bytes before accepting it.

The comparison uses bounded chunks on the failure path. An unreadable entry, a different length, or different content leaves the original publishing error available to the caller. The upstream handling of staging write failures is preserved.

  • Same Windows fixture on f3578e3: the identical entry is reused, then an existing XYZ file is incorrectly accepted for output ABC.
  • On 2dacec0: the identical file is reused, and the same-length and longer mismatches return an error. The recorded file is unchanged and staging files are cleaned up.
  • Six paired runs. All eight pipeline tests, crate formatting, strict Clippy, and asset policy passed.

Coordination claim · Windows file sharing rules

Please retain my Git author if moving the follow-up. If you fold the comparison or test extension into another commit, please add the following trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex. Synthetic Windows file test.

Review follow-up

The same Windows fixture on 2dacec0 fails because a second lookup returns the existing XYZ. With b80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes ABC after the reader closes. The next lookup hits ABC; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts.

Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5499569433 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T21:35:38Z. --- [#1324](https://github.com/Marvisak/VIctory/pull/1324) landed as `a73d59e` and covers the case where another writer publishes the correct cache entry before Windows rejects the rename. This branch keeps that behavior and checks that the existing file contains the converted bytes before accepting it. The comparison uses bounded chunks on the failure path. An unreadable entry, a different length, or different content leaves the original publishing error available to the caller. The upstream handling of staging write failures is preserved. - Same Windows fixture on `f3578e3`: the identical entry is reused, then an existing `XYZ` file is incorrectly accepted for output `ABC`. - On `2dacec0`: the identical file is reused, and the same-length and longer mismatches return an error. The recorded file is unchanged and staging files are cleaned up. - Six paired runs. All eight pipeline tests, crate formatting, strict Clippy, and asset policy passed. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7175238420) · [Windows file sharing rules](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew) Please retain my Git author if moving the follow-up. If you fold the comparison or test extension into another commit, please add the following trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex. Synthetic Windows file test. ## Review follow-up The same Windows fixture on `2dacec0` fails because a second lookup returns the existing `XYZ`. With `b80763c198d6b13ca97e7aa0ee354a6721cf43b0`, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes `ABC` after the reader closes. The next lookup hits `ABC`; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts. Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.
kotekompotek commented 2026-11-25 21:58:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:58:00Z.

Review: COMMENTED


Correct concurrency handling: on Windows the rename can fail only because a reader holds the published file — treating that as success iff the published bytes are identical is sound (the output is content-addressed work). Length check first, chunked compare, trailing-byte check — and unwrap_or(false) keeps genuine failures propagating. The paused-converter test exercises the real race. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065552681 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#pullrequestreview-6065552681). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:58:00Z. **Review:** COMMENTED --- Correct concurrency handling: on Windows the rename can fail only because a reader holds the published file — treating that as success iff the published bytes are identical is sound (the output is content-addressed work). Length check first, chunked compare, trailing-byte check — and unwrap_or(false) keeps genuine failures propagating. The paused-converter test exercises the real race. LGTM.
fuzeofficlal commented 2026-11-25 22:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:48:33Z.


Verified f8302c39 on Windows 11:

  • cargo xtask policy: 184 files ok; cargo clippy --locked -p victory-pipeline --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-pipeline: 8/8 passed (including an_open_concurrent_cache_entry_wins_only_if_identical).
  • Streaming 8 KiB chunk + length + EOF comparison in same_output cleanly handles concurrent publication without full-file copies and removes &tmp on collision. Clean git merge-tree against origin/main and #2797 (complementary across victory-pipeline and victory-loader).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175565954 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7175565954). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:48:33Z. --- Verified `f8302c39` on Windows 11: - `cargo xtask policy`: 184 files ok; `cargo clippy --locked -p victory-pipeline --all-targets -- -D warnings`: 0 warnings. - `cargo test --locked -p victory-pipeline`: 8/8 passed (including `an_open_concurrent_cache_entry_wins_only_if_identical`). - Streaming 8 KiB chunk + length + EOF comparison in `same_output` cleanly handles concurrent publication without full-file copies and removes `&tmp` on collision. Clean `git merge-tree` against `origin/main` and #2797 (complementary across `victory-pipeline` and `victory-loader`).
upstream-sync changed title from [PR #2828] Pipeline cache: accept identical output after a concurrent publication to [PR #2828] Pipeline cache: verify content when accepting a racing publication 2026-11-25 23:05:37 +00:00
andrewpozdnakov7-jpg commented 2026-11-25 23:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T22:23:00Z.


I resolved the conflict after #1324 landed. 2dacec0 keeps the upstream staging-write behavior and adds the byte check on rename failure.

The same synthetic test on main f3578e3 accepts XYZ where ABC was converted. The update reuses the identical file and rejects both mismatch controls. Six paired runs, eight pipeline tests, strict Clippy, formatting, and asset policy passed. The prior verified commit stays in the branch history.

Please preserve Git authorship if moving the comparison or test extension. If squashing it into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176293057 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7176293057). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T22:23:00Z. --- I resolved the conflict after #1324 landed. [2dacec0](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/2dacec0bf9f6358fda302af5315f36d4fff1fbc6) keeps the upstream staging-write behavior and adds the byte check on rename failure. The same synthetic test on main `f3578e3` accepts `XYZ` where `ABC` was converted. The update reuses the identical file and rejects both mismatch controls. Six paired runs, eight pipeline tests, strict Clippy, formatting, and asset policy passed. The prior verified commit stays in the branch history. Please preserve Git authorship if moving the comparison or test extension. If squashing it into another commit, please add this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
AwsAli05 commented 2026-11-25 23:06:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:06:46Z.

Review: COMMENTED


The first call now reports the publication mismatch. The next call can still report the wrong entry as a cache hit. I extended the Windows race fixture at 2dacec0 to call get_or_convert a second time after the error. The retry returned Ok(path) and read the original XYZ bytes for the conversion that produces ABC. The longer mismatch behaved the same way.

Can this rare path mark the mismatched entry unusable to subsequent lookups, or can the error explicitly tell the caller to invalidate it? A retry assertion would pin the expected behavior without adding any byte comparison to normal cache hits.

AI-assisted review and test using synthetic bytes.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066206225 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#pullrequestreview-6066206225). Originally posted by [AwsAli05](https://github.com/AwsAli05) on 2026-11-25T23:06:46Z. **Review:** COMMENTED --- The first call now reports the publication mismatch. The next call can still report the wrong entry as a cache hit. I extended the Windows race fixture at `2dacec0` to call `get_or_convert` a second time after the error. The retry returned `Ok(path)` and read the original `XYZ` bytes for the conversion that produces `ABC`. The longer mismatch behaved the same way. Can this rare path mark the mismatched entry unusable to subsequent lookups, or can the error explicitly tell the caller to invalidate it? A retry assertion would pin the expected behavior without adding any byte comparison to normal cache hits. AI-assisted review and test using synthetic bytes.
andrewpozdnakov7-jpg commented 2026-11-26 00:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T23:15:22Z.


Follow-up to the retry review in b80763c.

The same Windows fixture on 2dacec0 fails because a second lookup returns the existing XYZ. With b80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes ABC after the reader closes. The next lookup hits ABC; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts.

Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.

Please preserve the Git author if cherry-picking the fix or test. If folding either into another commit, please include Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177321029 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7177321029). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T23:15:22Z. --- [Follow-up to the retry review](https://github.com/Marvisak/VIctory/pull/2828#pullrequestreview-6066206225) in [b80763c](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b80763c198d6b13ca97e7aa0ee354a6721cf43b0). The same Windows fixture on `2dacec0` fails because a second lookup returns the existing `XYZ`. With `b80763c198d6b13ca97e7aa0ee354a6721cf43b0`, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes `ABC` after the reader closes. The next lookup hits `ABC`; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts. Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy. Please preserve the Git author if cherry-picking the fix or test. If folding either into another commit, please include `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Marvisak commented 2026-11-26 03:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:23:01Z.


Automated triage for the maintainers.

Verdict: proposed close (was needs work). Thanks for checking the production caller and for the candid answer. As you found, the shader cache keys entries by translator source, encoding, loop limit and container bytes, and on a publication error it already returns the in-memory translation (#2055). There is no known case where two writers publish different bytes for the same key, so the byte comparison and the .invalid marker in Cache::get_or_convert (crates/victory-pipeline/src/cache.rs) guard a case that does not occur, at the cost of an extra try_exists() on every hit. #1324's behaviour in main stays as is, which matches your own suggestion to defer.

This will be closed in 48 hours unless you push a change (for example, with a real case where the contents differ) or a maintainer removes the label.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180753076 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7180753076). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:23:01Z. --- <!-- victory-triage v1 head=b80763c198d6b13ca97e7aa0ee354a6721cf43b0 verdict=proposed-close at=2026-11-26T03:23:55Z --> Automated triage for the maintainers. **Verdict: proposed close** (was needs work). Thanks for checking the production caller and for the candid answer. As you found, the shader cache keys entries by translator source, encoding, loop limit and container bytes, and on a publication error it already returns the in-memory translation (#2055). There is no known case where two writers publish different bytes for the same key, so the byte comparison and the `.invalid` marker in `Cache::get_or_convert` (`crates/victory-pipeline/src/cache.rs`) guard a case that does not occur, at the cost of an extra `try_exists()` on every hit. #1324's behaviour in `main` stays as is, which matches your own suggestion to defer. This will be closed in 48 hours unless you push a change (for example, with a real case where the contents differ) or a maintainer removes the label. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-26 03:05:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:29:24Z.


Thanks for flagging the hot-path cost. I checked the production caller on 63bcca4: the shader cache keys entries by the translator source, encoding, loop limit, and container bytes. On a publication error it already returns the in-memory translation. The Windows test creates a mismatched entry deliberately while a reader holds it open. I have no production case where two conversions with that same key produce different bytes.

The two reviews identify a trade-off. The failure-only comparison in 2dacec0 has no extra I/O on hits, but the same test then returns the mismatched file on a second lookup. b80763c covers that retry at the cost of the marker check on each hit. With no observed production case, I'd leave #1324 as the current behavior and defer this follow-up until there's evidence that the retry case matters.

If you use the comparison or the Windows fixture later, please retain the original Git author. For a combined commit, please use:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180850949 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7180850949). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T02:29:24Z. --- Thanks for flagging the hot-path cost. I checked the production caller on `63bcca4`: the shader cache keys entries by the translator source, encoding, loop limit, and container bytes. On a publication error it already returns the in-memory translation. The Windows test creates a mismatched entry deliberately while a reader holds it open. I have no production case where two conversions with that same key produce different bytes. The two reviews identify a trade-off. The failure-only comparison in `2dacec0` has no extra I/O on hits, but the same test then returns the mismatched file on a second lookup. `b80763c` covers that retry at the cost of the marker check on each hit. With no observed production case, I'd leave #1324 as the current behavior and defer this follow-up until there's evidence that the retry case matters. If you use the comparison or the Windows fixture later, please retain the original Git author. For a combined commit, please use: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex.
cloph-dsp commented 2026-11-26 23:55:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T23:55:26Z.


Independent Windows verification of PR #2828 (keep mismatched cache publications out of retry hits).

  • Head: b80763c, merge-base f3578e3. OPEN, MERGEABLE/CLEAN, non-draft, no formal approval, no prior comment from me.
  • Toolchain: Windows, Rust 1.100.0/MSVC, cargo test --locked, worktree-local CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2 (repo pins 1.98.1; no clippy/rustup). No game data, synthetic file fixtures only, GPU/driver N/A.
  • Command: cargo test --locked -p victory-pipeline concurrent_publication_reuses_only_identical_entries
  • Result: test result: ok. 1 passed; 0 failed; 0 ignored; 7 filtered out (cache::tests::concurrent_publication_reuses_only_identical_entries).
  • git diff --check against merge-base f3578e3: clean (exit 0).
  • Negative control: test name absent from origin/main (0 hits).

Caveat: only the targeted synthetic test was run; the full crate suite and a real concurrent title workload were not exercised.

AI-assisted (Hy4 flash). No game assets, extracted shaders, keys or DRM content used or uploaded.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205997290 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7205997290). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T23:55:26Z. --- Independent Windows verification of PR #2828 (keep mismatched cache publications out of retry hits). - Head: `b80763c`, merge-base `f3578e3`. OPEN, MERGEABLE/CLEAN, non-draft, no formal approval, no prior comment from me. - Toolchain: Windows, Rust 1.100.0/MSVC, `cargo test --locked`, worktree-local `CARGO_TARGET_DIR`, `CARGO_BUILD_JOBS=2` (repo pins 1.98.1; no clippy/rustup). No game data, synthetic file fixtures only, GPU/driver N/A. - Command: `cargo test --locked -p victory-pipeline concurrent_publication_reuses_only_identical_entries` - Result: `test result: ok. 1 passed; 0 failed; 0 ignored; 7 filtered out` (`cache::tests::concurrent_publication_reuses_only_identical_entries`). - `git diff --check` against merge-base `f3578e3`: clean (exit 0). - Negative control: test name absent from `origin/main` (0 hits). Caveat: only the targeted synthetic test was run; the full crate suite and a real concurrent title workload were not exercised. AI-assisted (Hy4 flash). No game assets, extracted shaders, keys or DRM content used or uploaded.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2828:upstream-pr/2828'
git switch 'upstream-pr/2828'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2828'
git switch 'upstream-pr/2828'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2828'
git switch 'upstream-pr/2828'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2828'
git switch 'main'
git merge --squash 'upstream-pr/2828'
git switch 'main'
git merge --ff-only 'upstream-pr/2828'
git switch 'main'
git merge 'upstream-pr/2828'
git push origin 'main'
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!2826
No description provided.