Pipeline cache: verify content when accepting a racing publication #2826
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2828"
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?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T21:35:38Z.
#1324 landed as
a73d59eand 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.
f3578e3: the identical entry is reused, then an existingXYZfile is incorrectly accepted for outputABC.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.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
2dacec0fails because a second lookup returns the existingXYZ. Withb80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishesABCafter the reader closes. The next lookup hitsABC; 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.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:48:33Z.
Verified
f8302c39on 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 (includingan_open_concurrent_cache_entry_wins_only_if_identical).same_outputcleanly handles concurrent publication without full-file copies and removes&tmpon collision. Cleangit merge-treeagainstorigin/mainand #2797 (complementary acrossvictory-pipelineandvictory-loader).[PR #2828] Pipeline cache: accept identical output after a concurrent publicationto [PR #2828] Pipeline cache: verify content when accepting a racing publicationImported 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
f3578e3acceptsXYZwhereABCwas 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]
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
2dacec0to callget_or_converta second time after the error. The retry returnedOk(path)and read the originalXYZbytes for the conversion that producesABC. 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.
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
2dacec0fails because a second lookup returns the existingXYZ. Withb80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishesABCafter the reader closes. The next lookup hitsABC; 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]>.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
.invalidmarker inCache::get_or_convert(crates/victory-pipeline/src/cache.rs) guard a case that does not occur, at the cost of an extratry_exists()on every hit. #1324's behaviour inmainstays 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
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
2dacec0has no extra I/O on hits, but the same test then returns the mismatched file on a second lookup.b80763ccovers 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.
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).
b80763c, merge-basef3578e3. OPEN, MERGEABLE/CLEAN, non-draft, no formal approval, no prior comment from me.cargo test --locked, worktree-localCARGO_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.cargo test --locked -p victory-pipeline concurrent_publication_reuses_only_identical_entriestest result: ok. 1 passed; 0 failed; 0 ignored; 7 filtered out(cache::tests::concurrent_publication_reuses_only_identical_entries).git diff --checkagainst merge-basef3578e3: clean (exit 0).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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.