[systemd-devel] One failed restart leaves dependent units permanently dead

Shimin Guo smguo2001 at gmail.com
Fri Jun 10 22:40:14 UTC 2016


Tested on v229.

On Fri, Jun 10, 2016 at 3:37 PM, Shimin Guo <smguo2001 at gmail.com> wrote:

> Summary: If bar depends on foo via Requires and After, a failed restart on
> foo leaves bar permanently in the failed state, even if a later autorestart
> successfully brings up foo, even if bar is configured to always restart. Is
> this how systemd restart and dependency is supposed to work?
>
> To repro:
>
> foo.service:
>
> [Service]
> Restart=always
> RestartSec=5s
> Type=notify
> # sleep forever if /tmp/foo is present, otherwise fail
> ExecStart=/usr/bin/bash -c "if [[ -e /tmp/foo ]]; then systemd-notify
> --ready; while true; do sleep 99999; done; else exit 1; fi"
>
> bar.service
>
> [Unit]
> Requires=foo.service
> After=foo.service
>
> [Service]
> Restart=always
> RestartSec=5s
> ExecStart=/usr/bin/bash -c "while true; do /usr/bin/sleep 99999; done"
>
> - Initially, both foo and bar are running.
> - Then I rm'ed /tmp/foo and killed the main process for foo.service.
> - Systemd noticed that foo is dead and attempted to restart it.
> - In doing so, it stopped bar first, then foo.
> - Then it tried to start foo but failed because /tmp/foo was missing.
> - That put bar in a failed state with result 'dependency'.
> - Systemd then tried to restart foo every 5 seconds.
> - At this point I touched /tmp/foo, so foo started successfully.
> - However, systemd didn't bother with starting bar at all in the restart
> attempts after the first one.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160610/ef0345c9/attachment-0001.html>


More information about the systemd-devel mailing list