GPU/pipeline/library: serialize save() file writes/renames and use unique temp paths #566
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!566
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-566"
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?
@AscilCH on GitHub · 2026-11-25 02:17 UTC · original
AscilCH:fix/gpu-pipeline-library-save-tmp-race→main· +62 −6 · 1 files · 1 commits · openProblem
In
crates/victory-gpu/src/pipeline/library.rs, multiple background pipeline worker threads calllibrary::save(false)while shutdown callslibrary::save(true)(bypassing the 20 sSAVE_EVERYgate).save()releasedlibrary.saving.write()immediately afterserialise(), before callingreplace_library(dir, &tmp)andwrite_atomically(&dir.join(EARLY_FILE), ...), and both operations used fixed.tmpfilenames (host-pipelines.tmp/early-pipelines.tmp).If a second caller entered
save()while the first was still renaminghost-pipelines.tmpor writing/renamingearly-pipelines.tmp, the second caller truncated the same.tmpfile mid-rename (Mapped::create/std::fs::write), causing rename failures or replacinghost-pipelines.bin/early-pipelines.txtwith truncated/corrupt data. Additionally, ifserialise()failed,USED_CHANGEDhad already been cleared tofalse.Fix
SAVE_LOCKmutex inlibrary::save()spanning the full file-write and rename sequence while keepinglibrary.saving.write()scoped toGetSerializedSize()+serialise().temp_path(), keyed by PID and monotonic counter) and remove the temp file if writing or renaming fails.USED_CHANGEDifserialise()fails.temp_paths_are_unique_and_write_atomically_cleans_up.Verification
cargo test -p victory-gpu --locked pipeline::library::tests -- --test-threads=1: 5 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings: cleancargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
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.