fix(builder): a program the update can't replace keeps its record #3012
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3012
Loading…
Reference in a new issue
No description provided.
Delete branch "PedroRossi:fix/release-record-kept"
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?
Summary
After a failed program swap, a version folder forgets which release it holds.
place(
builder/crates/release/src/install.rs) deleteslongshot_release.json, the record of the release the folder holds,then renames the new program over the old one. When that rename fails (on Windows: the program is running, or a
scanner holds the file past the wait), the old program stays, but its record is gone, and the next start, finding no
record, checks the program again or downloads the release in full.
placenow moves the record tolongshot_release.json.previousbefore the swap and restores it if the move fails. If a backup already exists, it stops before changing the program or record. If restoration fails, it reports the error and leaves the backup in place.How to see it on main: make the rename fail (the test puts a folder where the program goes):
placereturns the error,and
longshot_release.jsonis gone.Read first:
place.Testing
Tested: on this PC (Linux), before the latest fix: the new test (
a_program_that_cannot_be_replaced_keeps_its_record) fails on main, the record gone, and passed with the earlier fix; the release crate's tests, clippy -D warnings, rustfmt. These checks are pending on the current head. Aspr createasks fora builder change: Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01: the game built by a builder from main @
1938a302with #3009, #3011 and #3012 merged, through the PC's job queue, played from the Market entrance repository save, then the control bridge's quit; exit 0. The release crate's code runs when a version is fetched or installed, not in a build or the game.mise run test(--strict) on main @1938a302, and on main with the earlier fix merged (together with #3009, #3010, #3011, #3013, #3014, from the same audit): 775 passed, 145 failed, 10 skipped both ways, so none failed only with that fix. The current head is pending. The 145 are named at the end.Still to test:
longshot_release.jsonkept and the next start not to download it again (a failed move can also happen on other platforms)Measurements
Nothing to measure: the change moves a small record file during an update.
Risks
A failed move restores the record when restoration succeeds; otherwise the backup remains and the error is reported. An existing backup stops the update. If removing the backup after a successful swap fails, the new record is not written.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run teston the current head is pending (failures from the earlier run that also fail onmainare named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
main; its run on the current head is pending.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.The 145 checks of
mise run testthat fail on main @1938a302on this PC too, with or without this change97 need a tool this PC doesn't have on PATH (
--strictfails them):48 fail on main itself: test_blocks_at_start.py, test_bug_report.py, test_cloth_kernels.py, test_cloth_loops.py, test_cloth_sphere.py, test_cloth_step12.py, test_cloth_step8.py, test_cloth_step9.py, test_control_picture.py, test_crash_record.py, test_crt_options.py, test_dev_update.py, test_dlssg_pace.py, test_draw_stream_visibility.py, test_framegen_resources.py, test_fsr_uniform_ownership.py, test_game_boundary.py, test_guest_holes.py, test_image_reaper_threads.py, test_image_view_retry.py, test_input_background.py, test_keyboard_option.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_log_levels.py, test_menu_keys.py, test_menu_save_atomic.py, test_mesh_first_types.py, test_oot_occ_raster.py, test_option_ids.py, test_perf_send.py, test_pipeline_tour.py, test_present_acquire_ahead.py, test_present_image_free.py, test_present_source_crop.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_readback_timeout_reuse.py, test_recording_admission.py, test_screensaver.py, test_switch_table.py, test_target_retention.py, test_tex_desc_memo.py, test_thinlto_tls.py, test_upscaler_round_trip.py, test_vram_compact.py, test_windows_display_startup.py, test_windows_on_linux.py
Found in an AI-assisted audit of the repository. The test, the fix, the runs and this description were made with Claude Code; I reviewed them.
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Tested in game: Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01: the game built by a builder from main @
1938a302with this change merged (and my two other release-crate pull requests), through the PC's job queue, played from the Market entrance repository save, then the control bridge's quit; exit 0. The release crate's code runs when a version is fetched or installed, not in a build or the game.WIP: fix(builder): a program the update can't replace keeps its recordto fix(builder): a program the update can't replace keeps its record@review
Recommendation: Approve. The test shows that the record is restored after a simulated failed rename, but the Windows failure the fix targets has not yet been tested. Restoration can also fail and leave the original problem in place. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change saves the installed release record before replacing the program and restores it if the move fails. It avoids a later recheck or download in the tested case, at the cost of an additional small file read and a recovery path that can itself fail.
Should fix (1): not blocking, but worth doing before merging.
builder/crates/release/src/install.rs:530: The restore write can fail after the original record has been deleted, and its error is ignored. (more on the line) Do: Preserve the existing record on disk, for example by moving it aside before the swap and restoring it on failure, and handle recovery errors explicitly.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/release/src/install.rs:528: The Windows held-program failure remains untested. (more on the line) Do: On Windows, hold the installed program open through the retries, attempt the update, and verify the old program and record remain and the next fetch recognizes them.@fixcan do L1.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, for the simulated failure: the author reports that the new test fails on base
1938a302and passes on this head. The actual Windows held-program case remains untested.Other systems: The release fetch path is used by the builder and can be invoked by the launcher. Linux and Windows use the changed record handling; the test simulates a rename failure with a directory, while Windows sharing violations and retry behavior still need a real run. The game and GPU rendering do not execute this path.
Switches: None.
Reviewed:
773c6dff3fagainst1938a302fe: Read both changed files, the installation and swap paths, repository contribution rules, standards and pull request template. Read the diff and both commit messages; checked record readers and fetch callers by search. No generated files or translations changed. The referenced adjacent Tooling AGENTS.md and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during review. The author reports the release crate tests, clippy and rustfmt passed on Linux; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -525,3 +527,2 @@let _ = std::fs::remove_file(dir.join(RECORD));crate::swap::while_held(|| std::fs::rename(made, program), &std::thread::sleep).map_err(|e| FetchError::io(program, &e))?;if let Err(e) = crate::swap::while_held(|| std::fs::rename(made, program), &std::thread::sleep) {L2 (should fix): The Windows held-program failure remains untested.
When: The automated test makes the destination a directory; it does not exercise Windows sharing violations, the retry wait, or restoration after an executable is held open.
Do: On Windows, hold the installed program open through the retries, attempt the update, and verify the old program and record remain and the next fetch recognizes them.
@ -527,1 +528,3 @@.map_err(|e| FetchError::io(program, &e))?;if let Err(e) = crate::swap::while_held(|| std::fs::rename(made, program), &std::thread::sleep) {if let Some(bytes) = before {let _ = std::fs::write(dir.join(RECORD), bytes);L1 (should fix): The restore write can fail after the original record has been deleted, and its error is ignored.
When: If the program is held and the filesystem becomes full or denies creation during the retry wait, the rename fails and restoring the record fails or leaves a partial file. The next fetch cannot use the record and must check the program or download it again.
Do: Preserve the existing record on disk, for example by moving it aside before the swap and restoring it on failure, and handle recovery errors explicitly.
@fix
Recommendation: Approve. The failed-swap path preserves the old record when restoration succeeds, but the Windows held-program case remains untested. A leftover backup also prevents later updates until it is resolved manually. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is 96751022e02a. I rebased it onto
main(ad7970c429). I edited its description to match the change.Changed
Not done
git show HEAD:builder/crates/release/src/install.rs > builder/crates/release/src/install.rs, then implement recovery and tests for interruptions before and after the program rename.Nothing was built or run: the checks run again on the new head.
The update moves the old release record aside and restores it if replacing the program fails. This avoids losing the record on that failure path, at the cost of requiring recovery if a backup is left behind.
Should fix (1): not blocking, but worth doing before merging.
builder/crates/release/src/install.rs:530: A leftover backup stops every subsequent update until someone manually resolves it. When: If the process stops after moving the record aside, the next fetch sees longshot_release.json.previous and returns an error instead of recovering and continuing the update. Do: Recover an interrupted swap safely on the next fetch, checking the program before restoring or discarding the backup, and test interruption on both sides of the program rename.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/release/src/install.rs:528: The Windows held-program failure remains untested. When: The automated test makes the destination a directory; it does not exercise Windows sharing violations, the retry wait, or restoration after an executable is held open. Do: On Windows, hold the installed program open through the retries, attempt the update, and verify the old program and record remain and the next fetch recognizes them.@fixcan do L3.Checks: they run again on this head; a failure shows on the pull request.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on the current head: the author reports that the earlier fix passed the regression test on Linux, but the revised fix and the Windows held-program case are still pending.
Other systems: The swap path runs on Windows and Linux. The regression test simulates a failed rename with a directory; it does not exercise a Windows-held executable. The game does not run this release-install code.
Switches: None.
Reviewed: 96751022e02a against
ad7970c429: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed install code and tests, and the swap helper. Skimmed the standards references and recorded runs. The separate review checklist and adjacent Tooling rules were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports the earlier fix passed its Linux regression test; current-head checks and a Windows held-program run are pending.
Overlaps and merge order: Not checked; the network is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@fix
The branch moved while I worked (someone pushed 96751022e02a), so I did it again on top of that. I didn't fix this pull request: the branch kept moving while I worked (now at 96751022e02a): ask again when it's quiet. Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
The branch moved while I worked (someone pushed 96751022e02a), so I did it again on top of that. I didn't fix this pull request: the branch kept moving while I worked (now at 96751022e02a): ask again when it's quiet. Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.