Skip to content

fix(install): the lock's two removals ignore one of the same folder at once, which busybox rm fails on - #3909

Merged
devswha merged 1 commit into
mainfrom
fix/install-lock-release-ignores-double-removal
Nov 15, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/install-lock-release-ignores-double-removal

Conversation

@devswha

@devswha devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner

What

Follow-up to #3905, from its last review (run at 5ba9332).

A regression #3905 brought in, only where rm is busybox's. The lock's holder sweeps .install.lock.gone-*
as soon as it holds the lock, while the run that just let the lock go is still removing its own
.install.lock.gone-<pid>. With GNU rm -rf the two removals of one folder never fail. busybox rm -rf lists the
folder, unlinks what is inside, then removes the folder, and it fails on an entry or folder the other process removed
meanwhile: rm: can't remove '.../.install.lock.gone-<pid>': No such file or directory, exit 1. Under set -e, that
fails either the run whose install had finished (its release) or the run that had just taken the lock (its sweep).
The reviewer saw it once in 1,200 installs at 5ba9332, never before the sweep, and never with GNU rm.

Fix. Both removals ignore failure (2>/dev/null || true), nothing else. The rename stays the step that matters;
neither removal has to succeed, as whatever is left is the next holder's to remove (the sweep #3905 added).

The test's waits. "leaves the lock to a waiter that claims it while the holder removes it" bounded its two waits
by loop turns (3000 x sleep 0.01), which took 43 s when the review broke the test on purpose, and the two waits
can follow one another, so its 60 s timeout could fire before the named message. Each wait is now bounded by
elapsed time (20 s, date +%s), the message says 20 s, and the timeout is 90 s.

docs/development.md said no race remains for all three installers. It now says install.sh releases the lock in
one rename, while install.ps1 and the plugin's installer still remove it in place and keep the narrow race (as
their own comments say). Neither is changed here.

Test. New, for both sides: "fails no run when the holder's sweep and a release remove the same folder at once,
with an rm that refuses a folder removed meanwhile (busybox)", once with the release inside the folder first and once
with the sweep. An rm stand-in removes the folder as busybox does (unlinks the pid, then fails with busybox's
message if the folder went meanwhile); the other run removes it only once the first is inside it, so the two always
meet. The test asserts that they did meet (the stand-in refused), both installs exit 0, bin holds the second's
release, and no .install.lock* is left.

No changelog fragment: the regression never shipped (no tag contains #3905's 4489fbb), and #3905's
install-lock-release-race.md still describes what users get.

Validation

Run Before (origin/main 4489fbb's install.sh) After (this PR)
Real busybox rm, forced, release side: install.sh's lock functions under busybox ash (BusyBox 1.37.0), busybox applets on PATH; run A's own rm -rf .install.lock.gone-<A> is held by strace -e inject=rmdir:delay_enter=3s after it unlinked the pid, while B takes the lock and sweeps A exits 1: rm: can't remove '<home>/.install.lock.gone-573045': No such file or directory; B exits 0 A and B exit 0; nothing left. The same busybox error still happens underneath (logged by the harness), now ignored
Real busybox rm, forced, sweep side: B's sweep is held the same way inside A's folder; A removes the folder only once B's sweep has unlinked the pid B exits 1: rm: can't remove '<home>/.install.lock.gone-576433': No such file or directory; A exits 0 A and B exit 0; nothing left; the error again logged underneath
New test, bun test ./scripts/install-binary.test.ts -t 'remove the same folder at once' (both sides) 2/2 fail: Expected: 0, Received: 1, rm: can't remove '.../.install.lock.gone-<pid>': No such file or directory 2/2 pass
Waits forced broken (scratch copy, deleted: the tar stand-in never writes first-holds), the claim-during-release test and both new cases the review measured 43 s with the old 3000-turn waits, against a 60 s timeout each fails at 19.5-20.0 s with "the first run never held the lock: no .../first-holds after 20 s", inside the 90 s timeout
HERDR_TEST_MODE=unit bun test --rerun-each 30 ./scripts/install-binary.test.ts 1080 pass, 0 fail (36 tests x 30)
bun run check fast through heavy-run.sh, on 6d001f4 exit 0: workflow syntax, generated types/themes, typecheck, build, unit 17455 pass, 0 fail, 54 skip
  • Also ran: sh -n install.sh and busybox ash -n install.sh; bun test ./scripts/conventions.test.ts ./scripts/changelog-fold.test.ts (32 pass).
  • The 30x rerun started before a one-line rewording of a comment in the new test; the committed file differs from what it ran only in that comment. check fast ran on the commit itself.
  • Skipped: bun run check full, the integration and browser suites (no server//src/ change), the Windows install (install.ps1 unchanged), and macOS (bash 3.2/BSD rm not run).

This PR touches install.sh, so it waits for GitHub's own checks, not only a local merge gate.

…t once, which busybox rm fails on

The holder's sweep of .install.lock.gone-* (#3905) and a releasing run's own
rm -rf of its .install.lock.gone-<pid> can remove the same folder together.
busybox rm -rf then fails with "No such file or directory" and, under set -e,
fails the finished install or the one that just took the lock. Both removals
now ignore failure: the rename is the step that matters, and whatever is left
is the next holder's to remove.

The claim-during-release test bounds its two waits by elapsed time (20 s each)
instead of loop turns, and its timeout covers both. docs/development.md says
the one-rename release holds for install.sh, while install.ps1 and the
plugin's installer keep the narrow race.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved installation reliability when multiple installs run at the same time, preventing cleanup conflicts from interrupting successful installs.
  • Documentation
    • Clarified how release installers handle lock cleanup and noted a remaining edge case involving three or more simultaneous installs.

install.sh now ignores removal errors during stale lock cleanup and lock release. Tests cover overlapping removal attempts in both orders. The documentation describes lock cleanup methods and notes a race when three or more installs start simultaneously.

Changes: Install lock cleanup

Layer / File(s) Summary
Ignore lock removal errors
install.sh
Stale lock cleanup and lock release now suppress errors when removing renamed lock directories.
Verify concurrent cleanup
scripts/install-binary.test.ts, docs/development.md
Race tests cover both orders for concurrent removal of the same renamed lock folder. The tests use time-based deadlines. The documentation describes installer lock cleanup methods and notes a race for three or more simultaneous installs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#3905: Introduces the rename-based lock release that this change retains and tests.
Merge Risk: Minimal · up to 6d001

The installer no longer fails when two runs try to remove the same leftover lock folder at once, which is the BusyBox regression reported in #3905. Tests cover this, and no merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title names the fix (ignoring failures in lock removal) and the trigger (busybox rm failing when one folder is removed concurrently). It is specific, but it is hard to read. It also says "the lock… Rewrite the title as a short, clear sentence. For example: "fix(install): ignore busybox rm failures when removing a lock folder concurrently".
Passed Passed checks: 3 passed

Check name Status Explanation
Description check Passed The description follows the template. It has a Change section that explains the problem, the fix, and the test changes. It has a Validation section that lists the commands run, their results, and the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the problem, the fix, and the test changes. It has a Validation section that lists the commands run, their results, and the checks skipped. It also states the changelog decision. It does not link a maintainer-agreed issue, but this PR is a follow-up to #3905, which the template's feature-linking rule does not cover.

Full details: Title check

Explanation

The title names the fix (ignoring failures in lock removal) and the trigger (busybox rm failing when one folder is removed concurrently). It is specific, but it is hard to read. It also says "the lock's two removals ignore one of the same folder at once", which is garbled and does not state the change clearly.

Resolution

Rewrite the title as a short, clear sentence. For example: "fix(install): ignore busybox rm failures when removing a lock folder concurrently".

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f5683e1 and 6d001f4.

Files selected for processing: 3

  • docs/development.md
  • install.sh
  • scripts/install-binary.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@devswha
devswha merged commit 6ec7ca9 into main Nov 15, 2026
13 checks passed
@devswha
devswha deleted the fix/install-lock-release-ignores-double-removal branch November 15, 2026 16:00
@devswha

devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 6d001f4a3fc2 as 6ec7ca972432 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Follow-up to #3905, whose review found that the new cleanup of leftover lock folders could fail an install with busybox rm when it and a releasing run removed the same folder at the same moment (seen once in 1,200 installs). Reproduced before merging on real BusyBox 1.37.0 by pausing one side's removal right after it deleted the pid file: on main the finished install exits 1 when the release side is held, and the sweeping install exits 1 when the sweep side is held; at this head both exit 0 and nothing is left, under dash, busybox ash and bash --posix. A rename that fails still fails the install, as before. The new tests fail on main, and each half goes red when its line is undone; with a broken stand-in they fail at about 20 s with their message, inside the 90 s timeout.

Left open, not blocking (LOW; needs another user's leftover folder and a reused pid): when a leftover that cannot be removed carries the same pid as the current run, that install finishes its work but exits 1 at release, and the next install breaks the stale lock and passes. On main any unremovable leftover failed every install at the sweep until removed by hand, so this is strictly better. The rename target could be given a name that cannot already exist.

Review reports: ~/.cache/ovis-tmp/reports/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant