Reuse a completed shader cache entry after a concurrent write #632

Closed
cnuonr wants to merge 1 commit from upstream-pr/632 into main
cnuonr commented 2026-11-28 02:07:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cnuonr on 2026-11-28T02:07:02Z.


Problem

Two shader translations can miss the same content-addressed cache key. If the first writer publishes the entry and a reader keeps it open on Windows, replacement by the second writer can fail with access denied. The existing complete entry is already available, but the second caller reports a shader conversion error.

Change

After a failed publication, remove the staging file and use the completed entry if a file now exists at the cache key. An unavailable destination still returns the original error.

Verification

cargo test --locked -p victory-pipeline --lib cache::tests passed all 8 tests on Windows. The new test reproduces the access-denied error on the original implementation with a file opened for shared reads. It checks that the final result remains readable and that the staging file is cleaned up.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5535663667 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/632). Originally posted by [cnuonr](https://github.com/cnuonr) on 2026-11-28T02:07:02Z. --- ## Problem Two shader translations can miss the same content-addressed cache key. If the first writer publishes the entry and a reader keeps it open on Windows, replacement by the second writer can fail with access denied. The existing complete entry is already available, but the second caller reports a shader conversion error. ## Change After a failed publication, remove the staging file and use the completed entry if a file now exists at the cache key. An unavailable destination still returns the original error. ## Verification `cargo test --locked -p victory-pipeline --lib cache::tests` passed all 8 tests on Windows. The new test reproduces the access-denied error on the original implementation with a file opened for shared reads. It checks that the final result remains readable and that the staging file is cleaned up.
trustno1-coder commented 2026-11-28 20:28:52 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T20:28:52Z.


Thanks for this. I'm closing it because main already does this: when the rename fails because another writer published the same key meanwhile, the existing entry is used (crates/victory-pipeline/src/cache.rs, with its own test of an entry published while open). The two conflict.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245316596 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/632#issuecomment-7245316596). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T20:28:52Z. --- Thanks for this. I'm closing it because main already does this: when the rename fails because another writer published the same key meanwhile, the existing entry is used (crates/victory-pipeline/src/cache.rs, with its own test of an entry published while open). The two conflict.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!632
No description provided.