When try-restart'ing a running service that is required by another running service, try-restart hangs indefinitely. Here is a very simple reproducer: 1. create foobar.service: ---------- [Unit] Description=Foo some bar [Service] ExecStart=/root/infinite_loop ---------- 2. create totoplouf.service: ---------- [Unit] Description=Toto goes plouf # # Note the requirement on the previous service # Requires=foobar.service After=foobar.service [Service] ExecStart=/root/infinite_loop ---------- 3. create the dummy "daemon" those services will run, and make it executable: ---------- #!/bin/bash while [ 1 ]; do sleep 60 done exit 0 ---------- 4. load the unit files, start them: # systemctl daemon-reload # systemctl start totoplouf.service # systemctl status foobar.service totoplouf.service foobar.service - Foo some bar Loaded: loaded (/etc/systemd/system/foobar.service) Active: active (running) since Thu, 04 Aug 2011 08:19:56 +0000; 8s ago Main PID: 5374 CGroup: name=systemd:/system/foobar.service ├ 5374 /bin/bash /root/infinite_loop └ 5375 sleep 60 totoplouf.service - Toto goes plouf Loaded: loaded (/etc/systemd/system/totoplouf.service) Active: active (running) since Thu, 04 Aug 2011 08:19:56 +0000; 8s ago Main PID: 5376 CGroup: name=systemd:/system/totoplouf.service ├ 5376 /bin/bash /root/infinite_loop └ 5377 sleep 60 5. try restarting foobar.service: # systemctl try-restart foobar.service This will hang forever. However, if you only foobar.service is running, then try-restart completes successfully and quickly. I'm seeing this issue on Fedora 16 with systemd 33.
So, running systemd in debug mode, here is what appears in kmsg when I run the try-restart command: [ 119.608142] systemd[1]: Accepted connection on private bus. [ 119.609325] systemd[1]: Got D-Bus request: org.freedesktop.systemd1.Manager.TryRestartUnit() on /org/freedesktop/systemd1 [ 119.609346] systemd[1]: Trying to enqueue job foobar.service/try-restart/replace [ 119.609379] systemd[1]: Installed new job foobar.service/try-restart as 274 [ 119.609395] systemd[1]: Installed new job totoplouf.service/try-restart as 275 [ 119.609415] systemd[1]: Enqueued job foobar.service/try-restart as 274 [ 119.610249] systemd[1]: totoplouf.service changed running -> stop-sigterm [ 119.611277] systemd[1]: Received SIGCHLD from PID 784 (infinite_loop). [ 119.611412] systemd[1]: Got SIGCHLD for process 784 (infinite_loop) [ 119.611843] systemd[1]: Child 784 died (code=killed, status=15/TERM) [ 119.611855] systemd[1]: Child 784 belongs to totoplouf.service [ 119.611877] systemd[1]: totoplouf.service: main process exited, code=killed, status=15 [ 119.612561] systemd[1]: totoplouf.service changed stop-sigterm -> dead [ 119.613311] systemd[1]: Converting job totoplouf.service/restart -> totoplouf.service/start [ 119.614253] systemd[1]: Got D-Bus request: org.freedesktop.systemd1.Manager.GetUnit() on /org/freedesktop/systemd1 [ 119.614445] systemd[1]: Received SIGCHLD from PID 786 (sleep). [ 119.614572] systemd[1]: Got SIGCHLD for process 786 (sleep) [ 119.614805] systemd[1]: Child 786 died (code=killed, status=15/TERM) [ 119.615217] systemd[1]: Got D-Bus request: org.freedesktop.DBus.Properties.Get() on /org/freedesktop/systemd1/unit/foobar_2eservice [ 119.618429] systemd[1]: Accepted connection on private bus. [ 119.621404] systemd[1]: Got D-Bus request: org.freedesktop.systemd1.Agent.Released() on /org/freedesktop/systemd1/agent [ 119.621563] systemd[1]: totoplouf.service: cgroup is empty [ 119.621869] systemd[1]: Got D-Bus request: org.freedesktop.DBus.Local.Disconnected() on /org/freedesktop/DBus/Local Note that this is pretty bad as try-restart is run during %post on yum update, so if it hangs, the whole yum process waits on it, and if the user kills it, he ends up with an unfinished yum transaction and a potentially broken system.
I just realized that I had forgotten one detail: this issue happens both with try-restart and restart.
Hmm, indeed. I guess there's a bug to fix here.
Fixed in git now. Thanks!
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.