Skip to content

Keep a second update from wiping the running update's transcript - #17020

Open
sundarshahi wants to merge 3 commits into
omacom:quattrofrom
sundarshahi:take-update-lock-before-transcript
Open

sundarshahi wants to merge 3 commits into
omacom:quattrofrom
sundarshahi:take-update-lock-before-transcript

Conversation

@sundarshahi

@sundarshahi sundarshahi commented Oct 29, 2026 •

Copy link
Copy Markdown

Starting omarchy update while one is already running wipes the running update's transcript. omarchy-update re-execs itself under script -qefc … /tmp/omarchy-update.log first and only takes the update lock inside that, so the second run's script(1) truncates the shared transcript on open, and only then reaches the lock and prints "An Omarchy update is already running." The first update keeps writing at its old offset, so everything it logged before the truncation is gone, and its closing omarchy-update-analyze-logs greps the damaged file. If the second run lands during the package upgrade, the "Updating linux initcpios" line is lost and the initramfs failure warning, the one that says to review the logs before restarting, cannot fire.

script(1) now opens the transcript with -a, so opening it never truncates it, and the update clears it itself once it holds the lock. Only the update that holds the lock ever clears the transcript, so a second update cannot wipe a running one's log, however close together they start. The order is unchanged from #16045: the transcript first, the lock inside it, so a terminal that closes still releases the lock with the update. The cost: a rejected second update's "already running" lines are appended to the running update's transcript.

Rebased on #16045. This PR first took the lock before the transcript instead, but then script(1) inherits the lock and keeps it while it shuts down, so closing the terminal no longer frees it at once: update-hangup-test.sh failed in 12 of 12 runs that way. A second version checked the lock before script(1) started, which left a window for two updates started at the same instant.

Testing, on the CI VM (Omarchy image, test/ci-vm):

  • The full suite passes.
  • update-hangup-test.sh alone, 12 copies, run side by side: 5 of 12 fail with this change and 5 of 12 on quattro, all at its lock check with BlockingIOError, so the test fails at random on its own. With the lock taken before the transcript it failed 12 of 12.
  • Without -a, update-lock-test.sh fails with not ok - second omarchy-update left the running update's transcript alone. Without the clear under the lock, it fails with not ok - update started its transcript afresh.
  • update-user-path-test.sh now points the copied updater at its own transcript, as update-lock-test.sh does, because an update now clears the transcript once it holds the lock. With a host transcript in place, it survives the test, and is cleared with that redirect removed.

The overlapping-updates test in update-lock-test.sh starts both updates fresh through the real script(1), with the transcript moved into the test's directory. It checks that the first update's output survives the second, and that a previous run's transcript is cleared.

This touches the lines next to #17012, which moves the transcript out of /tmp; whichever merges second needs a small rebase.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Keeps overlapping updates from erasing the running update's transcript.

  • A second update no longer clears the running update’s transcript.

Reviews (5) · Last reviewed commit: "Keep the PATH test off the host's update..." · Reviewed by Greptile

@sundarshahi
sundarshahi force-pushed the take-update-lock-before-transcript branch from 449d5eb to ffa8ae6 Compare November 1, 2026 04:26
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Nov 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at ffa8ae6. The bug is real and this fixes its cause. I found nothing to change.

What was checked, on a disposable Omarchy worker (util-linux 2.42.4):

  • A reproduction of my own, separate from the PR's test. It uses the real bin/omarchy-update, the real omarchy-update-lock and the real script(1), with the update's steps stubbed. It starts one update, then starts a second while the first holds the lock. On quattro the second run prints "An Omarchy update is already running." but has already wiped the first update's transcript. On this head, and on this head merged with current quattro (ae64a4b), the first update's output survives. With only bin/omarchy-update reverted, the transcript is wiped again.
  • The SHELL=/usr/bin/bash pin, tested with a login shell that closes inherited descriptors. With the pin, updates run normally. Without it, the first update loses the lock inside script(1) and never reaches its steps. So the pin is needed.
  • ./test/cli passes. The seven update test files pass (60/60): update-lock-test.sh, update-user-path-test.sh, update-sequence-test.sh, update-disk-space-test.sh, update-hook-security-test.sh, update-boot-verify-test.sh and channel-switch-test.sh. With the fix reverted, update-lock-test.sh fails on its new transcript assertion, so it is a real regression test.
  • In the full ./test/shell run, 6 of 413 files fail: ascii-test.sh, branding-about-animation-test.sh, first-run-test.sh, runtime-smoke-test.sh, agent-account-exec-test.sh and i18n-test.sh. All six fail the same way on the PR's fork point (d367a56). The first four also fail on current quattro. None of them touch the update path.

Second opinion: Codex (medium effort) and muse-wonder via pi (high thinking) reviewed the diff. Neither found a blocking defect. Both traced every entry path (fresh, already logged, lock inherited, omarchy-channel-set) and found none that runs unlocked, deadlocks, or reports itself as already running. They agreed with my reading, but they could see this session, so their agreement is not guaranteed independent.

One thing for the maintainer to weigh. It does not block the fix. The pin sets SHELL=/usr/bin/bash for everything the update runs, not just for script(1)'s choice of shell. Post-update hooks and mise up now see bash as $SHELL. Nothing in the repository reads $SHELL, and omarchy-hook runs hooks with an explicit bash, so only a user's own hook that launches "$SHELL" would notice. A narrower version keeps the pin for script(1) and puts the caller's SHELL= back at the front of script_command. That choice is left to you and the author.

This touches the lines next to #17012, which moves the transcript out of /tmp. #17012 keeps the old open-the-log-then-lock order, so it does not fix this bug. Whichever merges second needs a small rebase. This one now waits on the maintainer.

script(1) truncates the transcript when it opens it, and the lock was only
taken inside it. A second omarchy update therefore wiped the running update's
log before reporting that one is already running, and the running update's
initramfs check then read the wrong transcript. Check the lock before script(1)
starts; the lock itself is still taken inside the transcript, so a terminal
that closes releases it with the update.
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 15, 2026
@sundarshahi
sundarshahi force-pushed the take-update-lock-before-transcript branch from ffa8ae6 to a00bcf2 Compare November 15, 2026 05:57
@sundarshahi sundarshahi changed the title Take the update lock before starting the transcript Check the update lock before starting the transcript Nov 15, 2026
Comment thread bin/omarchy-update Resolved
The lock probe left a window: two updates started together could both
pass it, and the loser's script(1) then truncated the winner's transcript.
script(1) now appends, so opening the transcript never wipes it, and the
update clears it only once it holds the lock. The probe is no longer needed.
@sundarshahi sundarshahi changed the title Check the update lock before starting the transcript Keep a second update from wiping the running update's transcript Nov 15, 2026
Comment thread bin/omarchy-update Resolved
The update now clears its transcript once it holds the lock, so the fresh case cleared the real /tmp/omarchy-update.log. Point the copied updater at the test's own directory, as update-lock-test.sh does.
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed d529422: the logger, lock, analyzer, transcript tests, and related pull requests. This is a different fix for the same log-loss problem as #13937: that change gives every invocation its own transcript, so a rejected second invocation never opens the running update's file. The older fix takes precedence in the queue; both pull requests remain open for the maintainer's decision.

The regression scenario here is worth retaining: two fresh updates through the real script(1), checking that rejection of the second preserves the first transcript. I queued that test for adaptation into #13937's existing update-lock test. The append-and-clear production change is unnecessary with separate per-invocation logs.

Codex (high effort) reviewed the code and comparison; Opus 5.5 (high effort) and muse-wonder via pi (high thinking) also compared the fixes and agreed on #13937 under the oldest-first rule. Their independence is not guaranteed. Tests were not run on this revision because verification pauses for the competing fix; the previous review's results cover an older head. This item waits on the maintainer's choice between the fixes.

omarchybot added a commit to kvnloo/omarchy that referenced this pull request Nov 18, 2026
Adapt the overlapping-update regression from omacom#17020 to real script and lock entry points, and check the analyzer against current and legacy transcripts. This replaces the extracted-wrapper test and keeps fresh update and hangup fixtures inside their own temporary directories. Document how to analyze a retained transcript explicitly.

Co-Authored-By: sundarshahi <shahithakurisundar@gmail.com>
Co-Authored-By: GPT-6 High <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants