systemd stop job timeouts

The place to discuss Linux and Unix Operating Systems
Forum rules
Behave
Post Reply
User avatar
Grogan
Your Host
Posts: 2049
Joined: Sat Aug 21, 2021 10:04 am
Location: Ontario, Canada

systemd stop job timeouts

Post by Grogan »

Fuck, I hate systemd. Did I ever mention that I hate systemd?

Sometimes (on my rig) I get "a stop job is running for user manager for uid 1000" (or something worded like that) and the timeout is 120s. You can't interrupt it from the TTY, it won't take ctrl-c, you can either wait the 2 minutes (it's NEVER going to respond) or power off and fsck drives (that's actually faster, but no...)

The problem is the default setting in system.conf is only for services that don't specify their own values. I cut that down to 30s, but it doesn't help with most services.

I'm having this happen on the server too, it takes about 2 and a half minutes to reboot. About right for a 120s stop job timeout. I only have a java console on my remote KVM so I can't use it, so I have to try to figure out which service it is. I'm also assuming it's a stop job timeout (probably so because it's not every reboot). I changed the default value in system.conf but alas, it's not one governed by that. I would have said "so what... don't need to reboot often" but that's no longer true, at least once a week there are system updates and I don't want the server incommunicado for minutes. (mail servers need to stay up).

I know it's the user manager on my Arch system (sitting right in front of the console and I can read), so I can do something about that. Its service unit is in /usr/lib/systemd/system. Oh wait, if you edit that, it's going to get replaced next time there's a systemd update. Of course it will, it's systemd (I haven't stopped hating systemd since I started typing lol)

So the proper way is to use smoke and mirrors:

Code: Select all

systemctl edit --full user@.service
(servicename.service... that one is named user@)

This will create the service configuration in /etc/systemd/system to override the default. It will open in an editor (vi for me). Then systemd won't touch that and it's just up to your distributor to leave /etc/systemd alone (Arch does .pacnew files for configuration)

Or you could just copy the service file to /etc/systemd/system and edit it there :eh:

Either way, you're looking at shit like this:

Code: Select all

[Unit]
Description=User Manager for UID %i
Documentation=man:user@.service(5)
BindsTo=user-runtime-dir@%i.service
After=systemd-logind.service user-runtime-dir@%i.service dbus.service systemd-oomd.service
IgnoreOnIsolate=yes

[Service]
User=%i
PAMName=systemd-user
Type=notify-reload
ExecStart=/usr/lib/systemd/systemd --user
Slice=user-%i.slice
KillMode=mixed
Delegate=pids memory cpu
DelegateSubgroup=init.scope
TasksMax=infinity
TimeoutStopSec=120s
KeyringMode=inherit
OOMScoreAdjust=100
MemoryPressureWatch=skip
I'm setting TimeoutStopSec=10s for that particular one (I wouldn't do it for something like unmounting filesystems or closing down a db server etc.). I don't care what it's doing, it's probably got to do with some desktop portal bollocks on a tmpfs mount or something. I (UID=1000) am not even there at that point, I'm logged off and the system is either rebooting with ctrl-alt-del or shutdown as root :lol:

P.S. I think it tends to happen if I quit X, logout and CTRL-ALT-DEL quickly now that I think about it. It's stuck though, a disconnect that's never going to respond, so it doesn't need 120s.

P.P.S. Not reproducible if it does have anything to do with that. I just tested it twice. Quit Firefox, Quit XFCE, logout, CTRL-ALT-DEL and it was all tickety boo. :dunno:
User avatar
Zema Bus
Your Co-Host
Posts: 1115
Joined: Sun Feb 04, 2024 1:25 am

Re: systemd stop job timeouts

Post by Zema Bus »

I usually use 'shutdown -r now' or just 'reboot'.

Then there are those occasional timeouts with "no limit" :wtf: I haven't seen one in a long time though.
User avatar
Grogan
Your Host
Posts: 2049
Joined: Sat Aug 21, 2021 10:04 am
Location: Ontario, Canada

Re: systemd stop job timeouts

Post by Grogan »

At the console, init (or systemd in this case) traps CTRL-ALT-DEL and does shutdown -r now. Desktop environments generally intercept that and pop up their login/shutdown dialogs.

I like that because I'm not logged in as anyone.

Yes, I think serious things like unmounting filesystems or fsck jobs etc. have no limits. I've seen it, but I don't run into those kinds of problems, just this user manager for UID 1000 shit and I think since installing xdg-desktop-portal shit for that Cosmic. It doesn't happen that often, but 2 minutes pisses me off immensely when it does.
Post Reply