omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

omarchy-sleep-lock.service fails on resume: Restart=always re-runs systemd-inhibit while logind's sleep operation is still in flight

Open ki11e6 opened this issue 3 months ago • 19 comments

System details

  • Omarchy 4.0.0-1 (stable, not Quattro)
  • Arch Linux kernel 7.1.8-arch1-3
  • systemd 261 (261.2-1-arch)
  • Quickshell 0.3.0.r20.g28771c7-1
  • Hyprland 0.56.2-1 / Aquamarine 0.14.0-2
  • ASUS TUF Gaming FX505GT, Intel i5-9300H, hybrid Intel UHD 630 + NVIDIA GTX 1650 Mobile
  • Sleep state deep (S3), /sys/power/mem_sleep = s2idle [deep]
  • Shipped InhibitDelayMaxSec=15 drop-in active
  • Stock omarchy-sleep-lock.service and omarchy-system-sleep-monitor, no local overrides

What's wrong?

Summary

The fix for #6394 works as intended — omarchy-system-sleep-monitor now releases its delay inhibitor as soon as the lock is secure, because the --inhibited branch returns after consume_sleep_events runs the lock helper. But omarchy-sleep-lock.service is Restart=always with RestartSec=2s, so systemd immediately restarts the unit — and that restart lands while logind's sleep operation is still in flight, so systemd-inhibit refuses to register a new sleep inhibitor and the unit exits 1.

The result is a spurious unit failure on resume, plus a ~2 s window in which no Omarchy delay inhibitor is registered at all. I have one trace (see Notes), but the mechanism is visible in the shipped source and the unit properties, so I would expect it on every resume.

Evidence

From journalctl on the resume (timestamps to 6 dp so the ordering is unambiguous):

18:41:01.620675 systemd[1003]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 1.
18:41:01.634564 systemd[1003]: Started Lock Omarchy before suspend.
18:41:01.757854 systemd-inhibit[387442]: Failed to inhibit: The operation inhibition has been requested for is already running
18:41:01.759766 systemd[1003]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
18:41:01.759919 systemd[1003]: omarchy-sleep-lock.service: Failed with result 'exit-code'.
18:41:02.491985 systemd-logind[870]: Operation 'suspend' finished.
18:41:03.811668 systemd[1003]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 2.
18:41:03.816155 systemd[1003]: Started Lock Omarchy before suspend.

The decisive ordering is the middle two lines: systemd-inhibit fails at 18:41:01.757854, and logind only reports Operation 'suspend' finished at 18:41:02.491985 — 734 ms later. The restart is therefore attempting to take a --what=sleep inhibitor while logind still considers the sleep operation active, which is exactly the condition that produces "the operation inhibition has been requested for is already running".

The retry 2 s later succeeds (restart counter is at 2), because by then the sleep operation has finished. Locking itself was never affected — the lock went secure normally before suspend:

15:58:21.253 omarchy-shell[1187]: DEBUG qml: omarchy lock ... lock-requested
15:58:21.869 omarchy-shell[1187]: DEBUG qml: omarchy lock ... secure=true

Unit properties, for the record:

$ systemctl --user show omarchy-sleep-lock.service \
    -p Restart -p RestartUSec -p StartLimitBurst -p StartLimitIntervalUSec
Restart=always
RestartUSec=2s
StartLimitBurst=5
StartLimitIntervalUSec=10s

Expected result

A resume should not leave omarchy-sleep-lock.service in a failed state, and the delay inhibitor should be re-registered without a gap. Releasing the inhibitor promptly (the #6394 fix) and re-acquiring it reliably should not be in tension.

Actual result

The resume produced one status=1/FAILURE, and the inhibitor was missing for ~2.06 s (18:41:01.759919 → 18:41:03.816155).

Impact — deliberately not overstated

  • The failure is self-healing: the second restart succeeds. Locking before suspend worked correctly — this affects the window after resume, not the lock itself.
  • Exposure requires a suspend to be triggered inside the ~2 s gap. In practice the session is normally still locked from the previous suspend at that moment, so I have not observed an unlocked-suspend as a result of this, and I am not claiming one.
  • I specifically checked whether the rate limiter could latch the unit off permanently — it cannot via this path. One failure per resume against StartLimitBurst=5 / StartLimitIntervalSec=10s would need five suspend/resume cycles inside 10 s.

So: low severity, but a real defect, and it makes every resume log a unit failure that looks alarming while investigating unrelated suspend problems — which is how I found it.

Reproduction

  1. Stock omarchy-sleep-lock.service / omarchy-system-sleep-monitor on Omarchy 4.0.0.
  2. From an active, unlocked session, run systemctl suspend.
  3. Resume.
  4. journalctl --user -u omarchy-sleep-lock.service -b and journalctl -b | grep -E "Failed to inhibit|Operation 'suspend' finished".
  5. Observe the Failed to inhibit / status=1/FAILURE pair, followed by a successful restart 2 s later, and note that Operation 'suspend' finished is logged after the failure.

Possible directions (neither tested — offered only as a starting point)

  1. Retry instead of failing. Have the wrapper treat "the operation inhibition has been requested for is already running" as retryable rather than fatal, so the unit does not enter a failed state for a transient condition it will win a moment later.
  2. Decouple watching from inhibiting. The process needs to be long-lived to watch PrepareForSleep, but the inhibitor only needs to be held around each sleep. systemd-inhibit CMD couples the two lifetimes, which is what forces the exit-and-restart cycle in the first place. Holding the inhibitor via a file descriptor (org.freedesktop.login1.Manager.Inhibit) and releasing it on secure=true would let one persistent monitor serve every sleep cycle without ever restarting.

Direction 2 looks structurally cleaner but is a larger change; direction 1 is minimal. I have not implemented or tested either, so treat both as suggestions rather than proposals.

Notes

  • Observed on the first and so far only suspend/resume cycle on this machine, so n=1 — though the mechanism is visible in the shipped source and the unit properties, not just in the one trace.
  • Related: #6394 (the fix whose success creates this race). Distinct from #6359, which was a stale hyprlock process — there is no stale lock process here, and locking succeeded.
  • Found while diagnosing a separate NVIDIA suspend/resume compositor hang on the same resume; that part is #4891 and is not an Omarchy bug, so it is not reported here.

ki11e6 avatar Aug 17 '26 14:08 ki11e6

Second reproduction, restart-loop evidence, and a tested workaround

Second reproduction of this bug — same root cause, with the restart loop running much harder than the n=1 trace above, plus a tested user-level workaround.

System: Omarchy 4.0.0-1, CachyOS kernel 7.2.0-1-cachyos, systemd 261.2-1-arch, Hyprland 0.56.2-1 / Aquamarine 0.14.0-1, Framework Desktop (AMD Ryzen AI MAX+ 395, Radeon 8060S iGPU + RTX 5090 eGPU over USB4). Stock omarchy-sleep-lock.service / omarchy-system-sleep-monitor at the time of the failure.

The loop is worse than one failure per resume. In a single boot with two suspend/resume cycles, the restart counter climbed 13→20 in the first cycle and 21→27 in the second:

Aug 21 20:59:05 systemd[1425]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 13.
Aug 21 20:59:05 systemd-inhibit[819607]: Failed to inhibit: The operation inhibition has been requested for is already running
Aug 21 20:59:05 systemd[1425]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
... (counter 13 → 20)
Aug 21 21:48:29 systemd[1425]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 21.
Aug 21 21:48:29 systemd-inhibit[820540]: Failed to inhibit: ...
... (counter 21 → 27)

That's up to 8 consecutive failed restarts within a single resume — at or beyond StartLimitBurst=5 / StartLimitIntervalSec=10s. The "cannot latch off permanently" reasoning in the report assumes one failure per resume; a slow resume teardown (here: USB4/Thunderbolt re-enumeration) produces several. It did not latch off in these two cycles, but failed (start-limit-hit) — silently disabling the pre-suspend lock for all future suspends — is a realistic outcome on slower resumes. (Other units on this boot did hit start-limit-hit, so the mechanism is live.)

Tested workaround (user-level drop-in): ~/.config/systemd/user/omarchy-sleep-lock.service.d/restart.conf

[Unit]
StartLimitIntervalSec=0

[Service]
RestartSec=10
  • RestartSec=10 spaces the respawn past logind's operation window (resume teardown completes in 1–3 s), so re-acquisition lands after Operation 'suspend' finished.
  • StartLimitIntervalSec=0 removes the start limit so the unit can never be latched into failed (start-limit-hit).
  • Verified effective: RestartUSec=10s, StartLimitIntervalUSec=0, NRestarts=0 after applying; the unit survives subsequent suspend/resume cycles with no failures.
  • Gotcha: StartLimitIntervalSec must be in the [Unit] section — systemd silently ignores it under [Service] (Unknown key 'StartLimitIntervalSec' in section [Service], ignoring.).

This is a stopgap. The structural fix remains the direction-2 suggestion (decouple the inhibitor lifetime from the process lifetime via org.freedesktop.login1.Manager.Inhibit), or at minimum treating OperationInProgress as retryable (direction 1).

Filed by deepseek-v4-flash via opencode.

moedesux avatar Aug 21 '26 20:08 moedesux

Confirming this on different hardware and a different sleep state, plus one consequence I think is worth escalating.

Confirmation

  • Omarchy 4.0.0-1, kernel 7.1.8-arch1-3, systemd 261 (261.2-1-arch)
  • Framework Laptop 16, AMD Ryzen AI 9 HX 370 / Radeon 890M + NVIDIA RTX 5070 Mobile
  • Sleep state s2idle, not deep/S3
  • Stock unit, shipped InhibitDelayMaxSec=15 drop-in, no local overrides

To your "I have one trace ... but the mechanism is visible in the shipped source, so I would expect it on every resume" — it does happen on every resume here. The restart counter reached 33 over roughly two days of normal use, with the same failure/success alternation you described.

The consequence I would flag

You listed StartLimitBurst=5 / StartLimitIntervalUSec=10s in the unit properties but did not draw this out: these failures are not only noise, they can permanently disarm pre-suspend locking.

Back-to-back suspends here produced three starts in twelve seconds:

20:58:26.625357 systemd[user]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 31.
20:58:26.627035 systemd[user]: Started Lock Omarchy before suspend.
20:58:26.640518 systemd-inhibit[1733819]: Failed to inhibit: The operation inhibition has been requested for is already running
20:58:26.640978 systemd[user]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
20:58:35.798900 systemd[user]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 32.
20:58:35.805575 systemd[user]: Started Lock Omarchy before suspend.
20:58:35.822413 systemd-inhibit[1733912]: Failed to inhibit: The operation inhibition has been requested for is already running
20:58:35.822967 systemd[user]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
20:58:38.843735 systemd[user]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 33.
20:58:38.846741 systemd[user]: Started Lock Omarchy before suspend.

Five starts landed inside 39 s. Get five inside 10 s — which #8112 describes as reachable by cycling the lid a few times — and systemd stops restarting the unit at all. From then on no Omarchy delay inhibitor is ever registered again, and the screen silently stops locking before suspend, with nothing surfacing that until someone inspects the unit. That reads as a security consequence rather than a cosmetic failure, and it argues for a structural fix over a tuned RestartSec (which #8112 also found insufficient on its own).

Interim workaround

A user drop-in that removes the start limit and moves the retry past the tail of logind's operation:

# ~/.config/systemd/user/omarchy-sleep-lock.service.d/10-suspend-restart-race.conf
[Unit]
StartLimitIntervalSec=0

[Service]
RestartSec=4

StartLimitIntervalSec=0 is the part that matters — it cannot fix the race, but it guarantees the unit keeps re-arming instead of giving up permanently. RestartSec=4 only lands the retry after logind finishes the operation (~3 s here) so the common case stops failing.

rdockstader avatar Aug 26 '26 03:08 rdockstader

Follow-up, and a correction to my own workaround: RestartSec=4 does not avoid the collision. Measured on the next cycle:

21:27:42.907359 systemd[user]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 34.
21:27:42.911832 kernel: printk: Suspending console(s) (use no_console_suspend to debug)
21:27:42.934632 systemd-inhibit[1820606]: Failed to inhibit: The operation inhibition has been requested for is already running
21:27:42.935405 systemd[user]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
21:27:44.471814 systemd-logind[1164]: Operation 'suspend' finished.
21:27:47.660607 systemd[user]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 35.

Two things worth noting.

First, the retry landed 1.56 s before logind finished the operation, so a 4 s delay was simply too short — the window between the monitor exiting and the operation completing was ~5.5 s on this cycle. That window is set by how long suspend preparation takes (15 s InhibitDelayMaxSec plus the other delay inhibitors), not by a constant you can pick in advance.

Second, and more interesting: the collision happened on the way down, four milliseconds before the console suspended — not on resume. So this isn't only a resume-side race. Any restart scheduled during suspend preparation hits the same refusal, which I think reinforces reading in #8112 that the respawn-per-cycle design races the transition itself rather than any particular timing constant. I've since moved to RestartSec=10, but I'd expect a long enough preparation phase to defeat that too.

StartLimitIntervalSec=0 did do its job — counter went 34 → 35 with no give-up, which is the part I'd still recommend to anyone hitting this in the meantime.

rdockstader avatar Aug 26 '26 03:08 rdockstader

Corroborating this on Omarchy 4.0.1-1 (Quattro), with a variant worth noting: the same mechanism has a permanent form, not just the ~2s window described above.

Your trace recovers because logind reports Operation 'suspend' finished 734ms later, so restart #2 succeeds. On this machine the sleep operation never finishes — a suspend taken at boot wedges in the kernel and systemd-suspend.service stays activating (start) for the life of the session:

$ systemctl status systemd-suspend.service
     Active: activating (start) since Fri 2026-08-28 09:23:22 EDT; 25min ago
   Main PID: 1296 (systemd-sleep)

$ busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
    org.freedesktop.login1.Manager PreparingForSleep
b true

So systemd-inhibit never stops failing, and the unit restart-loops indefinitely:

Aug 28 09:48:25 systemd[1682]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 659.
Aug 28 09:48:25 systemd-inhibit[56462]: Failed to inhibit: The operation inhibition has been requested for is already running
Aug 28 09:48:25 systemd[1682]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE

662 restarts in 25 minutes, still climbing when I stopped counting. From then on there is no Omarchy delay inhibitor registered at all, for the whole session.

One detail that makes this worse than it needs to be: the unit never trips systemd's start-rate limiter and so never lands in failed where it would at least be visible. RestartSec=2 with the default StartLimitBurst=5 / StartLimitIntervalSec=10s puts it at exactly 5 starts per 10s — right on the boundary, so it loops forever instead of giving up. An explicit StartLimitBurst/StartLimitIntervalSec on the unit would turn an infinite silent loop into one visible failure, independent of whatever fixes the race itself.

For context on how the sleep operation gets wedged in the first place, I have filed that separately as #8758 — it is a boot-time lid/dock race that also strands NetworkManager ASLEEP. Happy to move any of this there if you would rather keep this issue scoped to the restart race.

xtr3m3b00t3r avatar Aug 28 '26 14:08 xtr3m3b00t3r

A third failure mode: when logind's operation never completes, the loop is unbounded — 3267 restarts in 2h04m — and a correction on the start-limit concern

The traces above all describe a transient collision: the respawn lands inside a suspend transition that finishes a few seconds later, so the unit fails a handful of times and recovers. There is a worse case. If logind's sleep operation never finishes at all, OperationInProgress stops being a race window and becomes a permanent state, and Restart=always spins for as long as the machine is up.

System: Omarchy 4.0.1-1, kernel 7.1.9-arch1-2, systemd 261 (261.2-1-arch), ASUS Vivobook Pro 15 N6506MV (Meteor Lake, i915), /sys/power/mem_sleep = [s2idle] deep. Stock unit, shipped InhibitDelayMaxSec=15 drop-in, no local overrides.

What happened

Lid close at 12:21:50. The lid switch bounced (Lid closed / Lid opened in the same second, Lid closed again 5s later), which put logind into a 30s suspend-retry cycle. Six cycles each entered s2idle and woke almost immediately. The seventh wedged in the kernel:

12:24:53 kernel: PM: suspend entry (s2idle)
12:24:53 kernel: Filesystems sync: 0.051 seconds
12:28:33 kernel: perf: interrupt took too long (2514 > 2500), lowering ...

Freezing user space processes never printed, and neither did PM: suspend exit. Only three kernel messages in the following two hours.

The wedge itself is not Omarchy's bug — it is a PCIe link failure on this machine's Genesys Logic GL9755 SD reader (pcieport 0000:00:1c.0: Data Link Layer Link Active not set in 100 msec, followed by mmc0 reading all-0xffffffff), and the kernel already carries a quirk for that part. I am not asking anyone to chase it. What is Omarchy's is what the sleep-lock unit does once logind is stuck.

The unbounded loop

Operation 'suspend' finished never arrived, so every respawn hit the same refusal, forever:

Restart counter 1 at 12:21:52 → 3267 at 14:26:29
Unrecovered from counter 25 (12:24:55, two seconds after the wedge) — 3242 consecutive failures
Failed to inhibit: ... already running 3261 occurrences
Duration 2h04m, ending only in a forced power-off

Each iteration spawns systemd-inhibit → bash → dbus-monitor. The thread's worst reported figure is 33 restarts over two days; this is two orders of magnitude past that in a single afternoon.

The correction

Get five inside 10 s — which #8112 describes as reachable by cycling the lid a few times — and systemd stops restarting the unit at all.

This cannot happen from the restart path with the shipped unit, and the reason is arithmetic. StartLimitBurst=5 permits five starts; you need a sixth inside StartLimitIntervalSec=10s to trip. Six starts require five gaps, and RestartSec=2 makes every gap ≥ 2s, so the sixth start always lands at ≥ 10s — at or past the window, which resets it.

Measured over 400 consecutive restarts from the wedged loop:

n starts: 400
gap min/avg/max: 2.248 / 2.250 / 2.252 s
max starts within any 10.0s window: 5      <- equals burst, never exceeds it
systemd ratelimit_below() would have tripped: 0 times

Zero trips in 3267 restarts. So the shipped configuration's failure mode is not the silent latch-off feared above — it is the opposite, an unbounded spin. The limiter sits exactly one gap-width outside reach.

Two consequences for the workarounds in this thread:

  • StartLimitIntervalSec=0 is a no-op against a hazard the shipped RestartSec=2 already cannot reach. It is not harmful, but it is not buying the protection it is described as buying — and it removes the only thing that would ever bound this loop if RestartSec were later lowered below 2s.
  • Raising RestartSec (4s, 10s) reduces the spin rate but not the spin. At RestartSec=10 this same two-hour wedge still yields ~730 failed starts.

None of this changes the recommended direction — decoupling the inhibitor's lifetime from the process's via org.freedesktop.login1.Manager.Inhibit fixes the transient race and the unbounded case together. It does argue that a tuned RestartSec is not a sufficient stopgap, and that whatever lands should treat "logind is wedged" as a state to back off from rather than retry into. A bounded retry that gives up and re-arms on the next PrepareForSleep would cap this at a handful of attempts instead of thousands.

Filed by Claude Opus 5 via Claude Code.

aronnaxlin avatar Aug 29 '26 06:08 aronnaxlin

Reconfirming on Omarchy 4.0.2-1, two releases newer

Second independent reproduction on a near-identical hybrid-NVIDIA laptop, confirming the prediction that this fires on (nearly) every resume. 4.0.2-1 stable today, stock unit and script, no overrides.

System: EVOO EG-LP5, i7-9750H + GTX 1660 Ti Mobile (TU116); kernel 7.1.9-arch1-2; systemd 261.2-1; Hyprland 0.56.2-1; Quickshell 0.3.1-1; /sys/power/mem_sleep = s2idle [deep]; InhibitDelayMaxSec=15 drop-in active (same as your setup).

Your trace's ordering, reproduced to the same shape — failure lands while the sleep operation is still in flight:

22:09:27.088041  omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 1.
22:09:27.137623  systemd-inhibit[7336]: Failed to inhibit: The operation inhibition has been requested for is already running
22:09:27.138359  Main process exited, code=exited, status=1/FAILURE
22:09:27.776339  systemd-logind[899]: Operation 'suspend' finished.   (639 ms after the failure; your trace: 734 ms)
22:09:29.363013  Scheduled restart job, restart counter is at 2.       (retry succeeds)

Observationally identical: the lock went secure normally before suspend, the failure is self-healing exactly as you described, and the ~2 s inhibitor gap after resume is the only real cost. The only new data points are (1) it still reproduces on 4.0.2-1, so the #6394 fix + Restart=always interaction is unresolved, and (2) it is not specific to your machine model — an EVOO EG-LP5 (Coffee Lake-H + TU116, the same hybrid topology as your FX505GT) produces the same 734 ms-style gap.

Direction 2 in your "possible directions" (decouple watching from inhibiting: hold the org.freedesktop.login1.Manager.Inhibit fd and release on secure=true, one persistent monitor, no restart cycle) still looks like the right structural fix and would eliminate this race class rather than retry around it.

Filed by big-pickle via opencode.

AmericanBub avatar Sep 02 '26 05:09 AmericanBub

Empirical check on the start-limit-hit question, at the shipped values

The thread is split on whether the restart path can latch the unit into failed (start-limit-hit) — a comment above, referencing #8112, treats it as reachable by cycling the lid; the arithmetic argument treats it as unreachable at RestartSec=2. I measured it instead of reasoning about it. The arithmetic holds, with margin.

Scratch unit, shipped values exactly (Restart=always, RestartSec=2, StartLimitBurst=5, StartLimitIntervalSec=10s), ExecStart=/bin/false so every start fails immediately:

NRestarts=17 over ~40s
start-limit events: 0
ActiveState=activating   (still retrying, never gave up)

Restart timestamps:

18:17:47.841061   18:17:54.591017   18:18:01.341001
18:17:50.091400   18:17:56.841008   18:18:03.591009
18:17:52.341011   18:17:59.090896

Gaps are 2.25s, not 2.0s — systemd adds ~250ms of scheduling overhead on top of RestartSec. Six starts therefore span ~11.25s against a 10s window. That is consistent with the field reports: a counter climbing 13→20 in one resume is ~18s of wall clock, nowhere near six-in-ten-seconds.

Control, identical but RestartSec=0.1: Result=start-limit-hit after 5 restarts. The guard is live — it is simply out of reach at the shipped delay.

Caveat on scope: this bounds the restart path only. Starts from elsewhere (a manual systemctl restart, or target-triggered starts) are not spaced by RestartSec and could still stack.

Two consequences:

  • StartLimitIntervalSec=0 is a no-op on the stock unit. Harmless, but it buys nothing, and it removes the only bound that would apply if RestartSec were later lowered. I've backed it out on my own machine.
  • The silent-permanent-disarm framing does not appear reachable via the restart path as shipped. The bug is still real — a spurious failure per transition, and a ~2s window with no Omarchy inhibitor registered — but that reads as cosmetic plus a small gap rather than a latent lockout, which changes how urgent the structural fix is.

System, for the record: MSI Vector A18, Ryzen 9 9955HX + RTX 5070 Ti Mobile, Hyprland compositing on the AMD iGPU, s2idle, Omarchy 4.0.4-1, systemd 261.2-1-arch. One refusal per resume, 30 across four boots, never start-limit-hit.

Filed by Claude Opus 5 (1M context) via Claude Code.

slhuckstead avatar Sep 17 '26 22:09 slhuckstead

Diagnosed against current quattro (902fd8aeb), read in source by Claude Opus 5.5 and independently by Codex Medium, which agreed on the mechanism.

The mechanism is confirmed in source. omarchy-system-sleep-monitor returns as soon as the lock helper reports the session secure (consume_sleep_events, line 14), which ends systemd-inhibit and releases the delay inhibitor while logind is still preparing to sleep. The unit is Restart=always with RestartSec=2, so it starts again every cycle, and the new systemd-inhibit asks logind for a sleep delay inhibitor while logind still has the sleep operation pending. logind refuses that with "The operation inhibition has been requested for is already running" for as long as PreparingForSleep is true, which covers both the tail of suspend entry and the stretch after resume until Operation 'suspend' finished. That matches every trace in this thread, including the one that collided on the way down. The measurements above on the start limiter also hold: restarts come about 2.25s apart, so StartLimitBurst=5 in 10s is never reached from this path, and the cost is the failed starts and the gap with no inhibitor, not a unit that latches off.

There is an open fix: #10455, which waits for PreparingForSleep to clear before taking the inhibitor and already says it fixes this issue. It was reproduced against real logind on a disposable Omarchy VM in its own review: the quattro monitor exits 1 with this exact error while a sleep job is held open, the branch waits and then holds the inhibitor, and reverting the fix brings the failure back. Neither the monitor nor its test has changed on quattro since that run.

Two other open pull requests fix the same thing differently, #13176 and #13782. #10455 is the oldest of the three and none of the others clearly does better, so that is the one this issue points at; which to take is the maintainer's call.

One case none of the three fully closes: when the suspend wedges in the kernel and PreparingForSleep never clears, as two comments above describe. #10455 gives up waiting after 30 seconds and tries anyway, so the loop drops from one failed start every 2 seconds to one every 32 or so, but it does not stop. The wedge itself is #8758.

#8112, #12495, #13160 and #13701 report the same failure later than this one.

This waits on the maintainer's decision on #10455.

omarchybot avatar Oct 08 '26 08:10 omarchybot

Adding a data point here, since my report on #13160 was closed as a duplicate (of #8112) and this is the oldest open thread for the bug.

It still reproduces on Omarchy 4.0.6-1, stock unit and script: 10/10 resumes across 4 boots logged Failed to inhibit: The operation inhibition has been requested for is already running, then status=1/FAILURE, then the restart succeeding ~2 s later. Machine: Lenovo ThinkPad P17 Gen 1, NVIDIA Quadro T1000 only, S3 deep, systemd 262, Hyprland 0.56.2-4.

The fix in #13782 works on that hardware: 3/3 lid cycles with 0 unit failures and 0 rejections logged, and the lock still secured before every suspend. Full results and timings: https://github.com/omacom/omarchy/pull/13782#issuecomment-6322283876

mudiam avatar Oct 21 '26 21:10 mudiam

Rechecked against current quattro (7075b61c6) after the 4.0.6 report above, read in source by Claude Opus 5.5 and independently by Codex Medium, which agreed on each point below.

Still unfixed on quattro. The monitor still returns as soon as the lock is secure and the unit is still Restart=always with RestartSec=2, so the 10/10 result on 4.0.6 is what the source predicts.

The #13782 hardware result does not change which fix this issue points at. Three clean lid cycles show #13782 working on that machine; they do not show #10455 failing, and #10455 was already shown against real logind on a disposable VM to wait out the operation and then take the inhibitor. With no defect named in the older fix, #10455 stays the one this issue points at, and choosing between them remains the maintainer's call. If you are able to, running #10455's head (6ab1ae62798de79841f4dd2ccd41ce71bbe42096) on the same P17 would put the two on equal footing.

Neither fix stops the loop when the suspend wedges in the kernel and PreparingForSleep never clears (#8758): each gives up after its budget, about 30 seconds for #10455 and about 10 for #13782, and the unit restarts into the same refusal. The shorter budget also has a cost in the ordinary case: the trace above that collided four milliseconds before the console suspended shows a restart can land during suspend preparation, which can run to the 15 second InhibitDelayMaxSec, longer than #13782 keeps retrying.

This still waits on the maintainer's decision on #10455.

omarchybot avatar Oct 21 '26 22:10 omarchybot

Ran #10455's head (6ab1ae6) on the same P17 as requested, using the same procedure as the #13782 test: 3/3 pass, with 0 Failed to inhibit, 0 unit failures and 0 insecure suspends. Each restart landed while PreparingForSleep was still true; it waited and inhibited 30–42 ms after logind's Operation 'suspend' finished, ~1.09 s after the restart (#13782: ~1.07 s, by retrying). So both fixes work on this hardware and are about equally fast. The post-resume window here was only ~1.05 s, so this doesn't separate their budgets. Per-cycle timings: https://github.com/omacom/omarchy/pull/10455#issuecomment-6328781612

mudiam avatar Oct 21 '26 23:10 mudiam

Thanks for running #10455's head on the P17. That answers the question the last comment asked: on the machine where stock 4.0.6 fails 10/10, #10455 passed all three of your cycles with no refused inhibitor, no unit failure and the lock secure before every suspend, taking the inhibitor 30 to 42 ms after logind finished the operation. With your #13782 run, both fixes have now passed the same test on the same hardware with similar re-acquisition times. The difference is in how: #13782 is refused and retries, while #10455 waits for PreparingForSleep to clear before calling systemd-inhibit, so in these cycles nothing was refused.

quattro is still at 7075b61c6, the same commit as the last check, so the bug is still unfixed there, and #10455 is still open at the head you tested (6ab1ae627) and still names this issue as one it closes. Claude Opus 5.5 checked that against GitHub; Codex Medium reviewed this comment against the thread and agreed with the conclusion, but could not reach GitHub to confirm the current state itself.

This result does not separate the two on the long-window case: your post-resume window was about 1.05 seconds, well inside both budgets. Neither fix stops the loop when the suspend wedges and PreparingForSleep never clears (#8758); #10455 gives up waiting after 30 seconds and tries anyway. Your test reports no new defect in either, so #10455 stays the one this issue points at, as the oldest of the three.

This waits on the maintainer's decision on #10455.

omarchybot avatar Oct 21 '26 23:10 omarchybot

Confirming on current stable, and adding one thing the report above does not cover: it fires twice per cycle (at the suspend wake and again at resume), and it is not only Omarchy's unit that gets refused.

System

  • Omarchy 4.5.0-3, kernel 7.2.11-arch1-1, systemd 262.1-1-arch, Hyprland 0.56.2, Quickshell 0.3.2.r7
  • ThinkPad P14s, /sys/power/mem_sleep = [s2idle], LUKS root + btrfs swapfile (hibernation verified working on this machine)
  • Stock omarchy-sleep-lock.service and omarchy-system-sleep-monitor, no local overrides; InhibitDelayMaxSec=15 drop-in active

Trace: suspend-then-hibernate (HibernateDelaySec=1min), 2026-11-07

19:54:34.490  systemd-logind[604]: The system will suspend and later hibernate now!
19:54:35.241  systemd-sleep[60733]: Performing sleep operation 'suspend'...
19:54:35.242  kernel: PM: suspend entry (s2idle)

19:55:37.226  systemd[704]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 4.
19:55:37.238  systemd[704]: Started Lock Omarchy before suspend.
19:55:37.265  omarchy-shell[1596]: DEBUG qml: omarchy lock ... fingerprint-resume: streak=1
19:55:37.295  systemd-inhibit[60869]: Failed to inhibit: The operation inhibition has been requested for is already running
19:55:37.296  systemd[704]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
19:55:37.850  systemd-sleep[60733]: System returned from sleep operation 'suspend-then-hibernate'.
19:55:37.880  systemd-sleep[60733]: Performing sleep operation 'hibernate'...
19:55:37.881  kernel: PM: hibernation: hibernation entry
19:55:38.168  fprintd[61009]: Failed to install a sleep delay inhibitor: GDBus.Error:org.freedesktop.login1.OperationInProgress: The operation inhibition has been requested for is already running

20:42:24.879  systemd[704]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 5.
20:42:25.010  systemd-inhibit[61155]: Failed to inhibit: The operation inhibition has been requested for is already running
20:42:25.011  systemd[704]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
20:42:25.550  systemd-sleep[60733]: System returned from sleep operation 'suspend-then-hibernate'.
20:42:25.551  kernel: PM: hibernation: hibernation exit
20:42:27.118  systemd[704]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 6.

Two restarts per cycle, both refused: one while logind is still executing hibernate (which follows the wake from the RTC alarm), one right at resume before hibernation exit. NRestarts went 3 → 6 across that single cycle. On a plain systemctl hibernate earlier the same day it was 1 → 3.

The refusal is logind's documented behaviour, not a transient

src/login/logind-dbus.c, manager_inhibit():

/* Don't allow taking delay locks while we are already
 * executing the operation. We shouldn't create the impression
 * that the lock was successful if the machine is about to go
 * down/suspend any moment. */
if (m->delayed_action && m->delayed_action->inhibit_what & w)
        return sd_bus_error_set(error, BUS_ERROR_OPERATION_IN_PROGRESS,
                                "The operation inhibition has been requested for is already running");

So the first restart attempt after releasing the inhibitor can only ever fail; it succeeds on a later retry once the operation finishes. The unit is effectively burning its retries at the one moment logind will not accept them.

Why it matters beyond the journal noise

fprintd hitting the same window is one thing, but the Omarchy unit is the one that must hold a sleep delay inhibitor for omarchy-system-sleep-monitor to lock before the machine sleeps. From the restart that fails until the retry that lands, there is no delay inhibitor from Omarchy at all — so a systemctl suspend/hibernate issued in that window (menu, SUPER + SHIFT + H, or a scheduled action) does not wait for the session to be locked. The lid path is covered by omarchy-system-lid-close locking up front; explicit requests are not.

Suggestion

Re-arm only after the operation has finished instead of racing it: keep the monitor process alive across the cycle (drop the inhibitor fd on PrepareForSleep(true), re-take it on PrepareForSleep(false)), or gate the restart on PrepareForSleep(false) so the retry never lands inside delayed_action's window.


Reported with the help of an automated agent (pi) that reproduced the cycle and gathered the traces on the affected machine, on behalf of @manolosuarezv.

manolosuarezv avatar Nov 08 '26 01:11 manolosuarezv

Following @jandrusk's request to add my multi-hour hang data here, this is a concise update from my related report in #15270: https://github.com/omacom/omarchy/issues/15270

Local test results

System: Omarchy 4.5.0-3, kernel 7.2.15-1-omarchy, systemd 262.1-1, Hyprland 0.56.2-4, NVIDIA RTX 4060 Ti with nvidia-utils 615.78.08-1.

  • PR #13782 (branch bartok9/sleep-lock-already-running): I tested its sleep-monitor logic through a local systemd overlay. The overlay remained effective after the November 5 Omarchy upgrade. Subsequent journal entries still showed repeated omarchy-sleep-lock.service failures/restarts and the Failed to inhibit: The operation inhibition has been requested for is already running message. This is an uncontrolled field report across suspend attempts, not a cycle-for-cycle comparison with another PR.
  • On November 12, one deep-suspend attempt was followed by NVIDIA NVRM errors (including kgmmuInvalidateTlb_GM107, dmaAllocMapping_GM107, and nvAssertFailedNoLog). That boot's journal ended without a PM: suspend exit entry; I had to power-cycle the machine. The journal also contains blocked-task reports involving nvidia-modeset during another suspend episode. These observations are correlated; I cannot establish that NVIDIA caused the inhibitor race or the hang.
  • PR #10455 (branch fix-sleep-monitor-restart-loop, head 6ab1ae6): I have now installed the PR helper as the active local overlay. Its targeted shell tests passed 5/5. I have not yet completed a real suspend/resume cycle with this overlay, so I cannot report a runtime outcome for #10455 yet.

The November 12 journal is the evidence for the no-resume/power-cycle episode. It does not establish whether systemd-suspend.service remained in activating; I did not capture that status during the hang. I will add the #10455 runtime result after testing it.

PR references: #13782 https://github.com/omacom/omarchy/pull/13782 · #10455 https://github.com/omacom/omarchy/pull/10455

kellen-xavier avatar Nov 16 '26 14:11 kellen-xavier

@kellen-xavier, a note on reading the #13782 result. That PR runs systemd-inhibit as a child and sends its stderr to a temp file. An "already running" rejection is retried every 0.25 s, up to 40 times, and the unit stays up meanwhile. The message reaches the journal, and the unit exits 1, only after all 40 attempts are refused (about 10 s). So repeated Failed to inhibit … already running lines followed by unit restarts mean one of two things:

  1. The overlay wasn't the code that ran. A package upgrade reinstalls /usr/bin/omarchy-system-sleep-monitor, which replaces a patched copy there. systemctl --user cat omarchy-sleep-lock shows which ExecStart the unit uses; check that file for the retry loop.
  2. The suspend stayed in flight for more than 10 s, which is the wedged case in #8758. Neither PR handles it, and it may fit your Nov 12 hang.

For comparison, here is one boot on my P17 (Quadro T1000 only, S3 deep, driver 615.78.08). The sleep monitor was swapped several times during the boot, so the counts are split by which version was installed at each suspend:

/usr/bin/omarchy-system-sleep-monitor Suspends Unit exits with status=1/FAILURE
Stock (3 on 4.5.0-rc3, 1 on 4.5.0-1; the stock script is byte-identical in rc3 and 4.5.0-3) 4 4
#13782 (on rc3) 4 0
#10455 6ab1ae6 (3 on rc3, 4 on 4.5.0) 7 0

Stock is still unfixed on 4.5.0, and both PRs held up under ordinary use, not just in the lid-cycle tests I posted earlier.

mudiam avatar Nov 16 '26 19:11 mudiam

@mudiam Thanks, that distinction is helpful. For my November 12 test, I checked the effective unit and the journal identifies the executable as omarchy-system-sleep-monitor-pr13782; the archived helper matches the PR’s retry implementation. So the “wrong code ran” explanation does not appear to fit that test.

At 23:11 on November 12, the deep-suspend attempt produced NVIDIA NVRM errors, and that boot’s journal ended without a PM: suspend exit before I had to power-cycle the machine. This is consistent with the sleep operation remaining in flight beyond the retry window, but I did not capture PreparingForSleep or systemd-suspend.service state during the hang, so I cannot confirm that diagnosis.

I have now installed #10455 (6ab1ae6) as the active local overlay and its targeted tests passed 5/5. A real suspend/resume cycle with #10455 is still pending. I understand that its 30-second wait limit would not resolve a kernel suspend wedge that never clears.

kellen-xavier avatar Nov 17 '26 14:11 kellen-xavier

@kellen-xavier, thanks for checking the executable. That rules out the first explanation, so case 2 is the one left. It also means the sleep monitor didn't cause the hang. NVIDIA errors and a boot journal with no PM: suspend exit point to the suspend itself getting stuck in the kernel or driver, and the sleep monitor only reports that. Neither PR can fix that, as you said. What #10455 should change is the ordinary case, where a sleep finishes but takes a little longer: no Failed to inhibit … already running lines and no status=1/FAILURE restarts of omarchy-sleep-lock.service.

If it hangs again and the machine still answers over SSH or on a text console, these readings before the power cycle would settle it:

busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager PreparingForSleep
systemctl status systemd-suspend.service --no-pager
cat /sys/power/state /sys/power/mem_sleep

PreparingForSleep stuck at true with systemd-suspend.service still activating would confirm a suspend stuck in flight. After a power cycle, journalctl -b -1 -k | grep -E 'NVRM|PM:' shows how far the kernel got. If the NVRM errors follow PM: suspend entry (deep) and no PM: suspend exit ever comes, the driver hung during suspend. That is a report for NVIDIA (nvidia-bug-report.sh), not for Omarchy.

mudiam avatar Nov 20 '26 21:11 mudiam

Adding a fresh reproduction on 4.5.0-3, plus one data point I did not see in the thread: the failure window scales with the actual suspend/resume duration, so a slow resume turns the usual one-or-two failed restarts into a multi-second loop with no inhibitor registered.

System: Omarchy 4.5.0-3 (stock unit and script, no overrides), kernel 7.2.15-4-omarchy, systemd 262.1, Hyprland 0.56.2, NVIDIA 580.178.04, ASRock B450M Pro4-F / Ryzen 7 2700 / GTX 1080, S3 deep.

Trace (2026-11-27, S3 resume; systemctl --user show gives Restart=always, RestartUSec=2s):

23:05:49 kernel: PM: suspend exit
23:05:49 systemd[1056]: omarchy-sleep-lock.service: Scheduled restart job, restart counter is at 3.
23:05:49 systemd-inhibit[134402]: Failed to inhibit: The operation inhibition has been requested for is already running
23:05:49 systemd[1056]: omarchy-sleep-lock.service: Main process exited, code=exited, status=1/FAILURE
23:05:51 ... restart counter is at 4.  (+ same failure)
23:05:53 ... restart counter is at 5.  (+ same failure)
23:05:55 ... restart counter is at 6.  (+ same failure)
23:05:56 systemd[1]: Finished System Suspend.
23:05:56 systemd-logind[930]: Operation 'suspend' finished.
23:05:58 ... restart counter is at 7.  (this start succeeds)

Four consecutive refusals, each 2s apart, and the unit only stays up once logind reports Operation 'suspend' finished. The lock itself was secured before suspend; this is the post-resume window only.

Why the window was 7.5s here: this box runs NVreg_PreserveVideoMemoryAllocations=1 with ~5.9GB of VRAM held by a local LLM server, so the NVIDIA driver dumps/restores ~6.6GB across the cycle (PM: suspend exit 23:05:49 → Finished System Suspend 23:05:56.8). The restart cadence is fixed at 2s, so the number of failed starts is set by how long the sleep operation takes, not by a fixed 2s race. That is the case a fixed RestartSec bump cannot cover, and it argues for waiting on PreparingForSleep to clear (#10455). #13782's bounded retry also covers this window, but only just: 7.5s is inside its 10s budget with ~2.5s to spare, so a slightly slower resume would exhaust it.

No new issue — same mechanism, just adding the slow-resume data point.

kreker06 avatar Nov 27 '26 20:11 kreker06

Thanks for capturing this on stock 4.5.0-3. Logind finished the sleep operation about seven seconds after PM: suspend exit. Four inhibitor requests were refused during that window, and you report that the next restart recovered. That gives us a baseline for a slow S3 resume.

Codex High checked the trace against current quattro and the #10455 diff. Opus 5.5 High and muse-wonder via pi, thinking high reviewed the same evidence and agreed that it fits the existing race. #10455 waits for logind’s PreparingForSleep to clear and remains the linked fix awaiting the maintainer’s decision.

omarchybot avatar Nov 27 '26 20:11 omarchybot