Systemd hangs when attempting shutdown

gentoohangrebootshutdownsystemd

Distro: Gentoo
systemd: 242

For a while, on both of the systems I have here, I've been unable to do a proper shutdown (halt, poweroff, reboot). It gets most of the way through shutting down services and such, and then just stops. I have to use magic SysRq keys to finish the job.

I finally enabled debug-shell.service and took a look. It turns out, systemd is hanging at 100% CPU at some point. There are usually 1 or 2 services that still have processes, some of which are zombies (I assume because systemd would normally remove them but isn't working).

This is about all I've been able to determine. What else can I do to diagnose the issue?

EDIT: Example screenshot (cropped): https://imgur.com/OVOozrI The contents actually vary considerably, as the order of things may be different.

EDIT 2: Relevant part of the syslog. I don't see much interesting in there. The only thing that was "stopping" without a "stopped" was Dovecot. However, you can see at the bottom, it did finally exit. This seems to have been just before systemd started hanging. I remember from the debugging shell, Dovecot was left as a zombie. Just a little while ago, I tried shutting down Dovecot (successfully) and then doing the reboot, but systemd still hangs.

Best Answer

It indeed looked like this bug which affects the initial release of systemd 242: https://bugs.gentoo.org/685002 (upstream: https://github.com/systemd/systemd/issues/12335).

And, in fact, the change from 242 to 242r1 (in gentoo's versioning) was to apply this patch: https://gitweb.gentoo.org/repo/gentoo.git/commit/sys-apps/systemd?id=eb1d80e6a30d09f9f139877c5b754c8a8e918d7a

Related Question