omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

system-update widget: concurrent checkupdates races on multi-monitor, so the update icon shows on only one bar

Open EJ-Monkey opened this issue 2 months ago • 4 comments

What happens

On a multi-monitor setup, the omarchy.system-update bar widget shows the "update available" icon on only one monitor's bar. Which monitor wins is non-deterministic — forcing a re-check with omarchy-shell omarchy.system-update refresh reliably moves the icon to the other bar rather than showing it on both.

What I expected

The update icon appears on every monitor's bar, since the update state is a property of the system, not of a monitor.

Root cause

SystemUpdate.qml is instantiated per bar, and each instance runs its own check with triggeredOnStart: true:

Process {
  id: updateProc
  command: ["omarchy-update-available"]
  onExited: function(exitCode) { root.updateAvailable = exitCode === 0 }
}
Timer { interval: 21600000; running: true; repeat: true; triggeredOnStart: true }
visible: updateAvailable

omarchy-update-available calls checkupdates, which uses a single shared temporary pacman database per user:

CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${UID}/"
trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT
fakeroot -- pacman -Sy --disable-sandbox-filesystem --dbpath "$CHECKUPDATES_DB" ... &> /dev/null

With two monitors the two instances invoke this simultaneously and contend on the pacman lock. The loser's pacman -Sy fails, the failure is swallowed by &> /dev/null, its pacman -Qu therefore returns nothing, and omarchy-update-available prints "Omarchy is up to date" and exits 1 — so that bar sets visible: false. The trap compounds it: whichever invocation exits first deletes db.lck out from under the one still running.

Steps to reproduce

  1. Two or more monitors, each with a bar.
  2. Have a pending Omarchy package update.
  3. Restart the shell (or run omarchy-shell omarchy.system-update refresh).
  4. The icon appears on exactly one bar.

Reproducible directly, without the shell, by running two checks concurrently:

$ omarchy-update-available & omarchy-update-available & wait
omarchy 4.0.2-1 -> 4.0.3-1      # exit 0
Omarchy is up to date           # exit 1   <-- wrong

Run sequentially, the same command is consistently correct (3/3 exit 0), which confirms contention rather than a flaky check.

Suggested fix

Serialize the check — e.g. wrap the checkupdates call in omarchy-update-available with flock on a per-user lock file so concurrent callers queue instead of racing. That fixes every caller at once rather than only the widget. Alternatively, have a single shared poller publish one result to all bar instances, which would also drop N redundant pacman -Sy calls per refresh on multi-monitor systems.

A related smaller issue: omarchy-update-available cannot distinguish "no updates" from "the check failed", because checkupdates failures are discarded. Treating a failed check as "up to date" is what makes this user-visible.

System details

Omarchy 4.0.2-1
Kernel 7.1.9-arch1-2
Hyprland 0.56.2
CPU Intel Core i5-7400
GPU NVIDIA GP104 [GeForce GTX 1070]
Monitors 2
pacman-contrib 1.13.1-1

EJ-Monkey avatar Sep 10 '26 02:09 EJ-Monkey

Confirmed on 3 monitors. Omarchy-dev 4.0.0.r2128.gb679363-1, Quickshell 0.3.1, Hyprland 0.56.2, pacman-contrib 1.13.1-1.

With omarchy-dev 4.0.0.r2128.gb679363-1 -> 4.0.0.r2153.g9c5482c-1 pending, the icon appeared on only one bar. Diagnostic evidence:

  • A single omarchy-update-available invocation reported the update and exited 0.
  • Three invocations launched concurrently: two exited 0 with update results, one printed "Omarchy is up to date" and exited 1 — same contention pattern described here, with the loser treated as no-updates.

Matches the suggested direction: one shared check published to all bar instances would fix the race and drop the redundant N-1 pacman -Sy calls per refresh.

DanielJBurbridge avatar Sep 17 '26 01:09 DanielJBurbridge

I checked this against quattro at be7c7bf37, and the race is still there. Every monitor's bar builds its own SystemUpdate.qml, and each one runs omarchy-update-available from its own timer at startup, and again on every refresh, which now goes to every bar. checkupdates syncs into one shared /tmp/checkup-db-$UID and deletes db.lck when it exits, so a caller that loses the race gets no result. bin/omarchy-update-available:31 drops that error and reports "up to date", and the widget hides its icon. Nothing on quattro has changed this yet.

#11480 is the fix for this issue and is already linked to it. It puts a flock in $XDG_RUNTIME_DIR around checkupdates, so the bars wait for each other instead of racing. An earlier review reproduced the race on a disposable Omarchy worker with a real pending omarchy update: on quattro, 10 of 15 concurrent checks reported up to date, on the branch 0 of 15, and with the lock reverted 8 of 15. That pull request is being reviewed separately. Its latest revision is waiting for a second opinion before it can be labelled verified again.

This is related to #9798 but is not a duplicate. That issue is about a failed check of any kind being shown as "up to date". #10066 handles that case, and it does not stop the race. Moving the check into one shared service that feeds every bar, as both reports suggest, would remove the race altogether. Whether to do that instead is the maintainer's decision.

Reviewed by Claude Opus 5.5, with a second opinion from Codex Medium, which read the source on its own and came to the same conclusions. Its independence is not guaranteed. It added that #11480 still runs unlocked when the runtime directory can't be created, which is a deliberate fallback for session-less callers and never happens to the bar. It also noted that callers outside omarchy-update-available don't take the lock. Neither affects this symptom. Nothing was run for this issue itself.

Nothing is needed from you. This waits on the maintainer to decide on #11480.

omarchybot avatar Oct 11 '26 11:10 omarchybot

Confirmed on Omarchy 4.0.4-1 with two monitors (eDP-1 and HDMI-A-1). The update icon is visible on only one bar; the user configuration includes the stock omarchy.system-update widget without an output restriction.

On 2026-10-19, we ran the installed /usr/bin/omarchy-update-available against an isolated temporary database by setting CHECKUPDATES_DB to a new directory under /tmp. OMARCHY_PATH was /usr/share/omarchy. No package updates were installed and no bar configuration was changed.

One sequential check, two checks launched together using a threading barrier, then another sequential check produced:

Invocation Exit code Output Duration
Sequential before 0 omarchy 4.0.4-1 -> 4.0.5-1 3.45 s
Concurrent A 0 omarchy 4.0.4-1 -> 4.0.5-1 1.37 s
Concurrent B 1 Omarchy is up to date 0.12 s
Sequential after 0 omarchy 4.0.4-1 -> 4.0.5-1 1.37 s

The two concurrent checks shared the same isolated database, reproducing disagreement without competing with the live bar's default database. This confirms the concurrent false-negative behavior on 4.0.4-1. We did not capture the underlying pacman error, since the installed helper suppresses it, and did not test the branch in #11480.

Diagnostics and this comment were prepared with Codex at the user's request.

NjengaFelix avatar Oct 19 '26 06:10 NjengaFelix

Still happens on 4.0.5-1 with two monitors (laptop eDP + external HDMI). Minimal repro, outside the shell:

(omarchy-update-available; echo "A exit=$?") & (omarchy-update-available; echo "B exit=$?") & wait
# A: omarchy 4.0.5-1 -> 4.0.6-1 (exit 0)
# B: Omarchy is up to date      (exit 1)

Serializing the callers fixes it: wrapping both in flock "$XDG_RUNTIME_DIR/omarchy-update-available.lock" makes both report the update. I'm running a cloned widget with that wrapper and both bars now agree, which matches the approach in #11480.

TobiasVeiga00 avatar Oct 20 '26 02:10 TobiasVeiga00