Discussion:
A question about the race condition between two service
(too old to reply)
piliu
2018-11-01 08:34:10 UTC
Permalink
Hi,

I encounter an issue during the poweroff. In my bash script, firstly I
use poweroff cmd to start systemd-poweroff.service, and use reboot cmd
as a bake up if the poweroff fails. But during tests, many times, the
machine is rebooted directly, without waiting for the result of poweroff.
Since both of the cmds use "systemctl" without --no-block option, so I
think they should execute one-by-one. But the test result is not.
Any suggestion?

Thanks,
Pingfan
Reindl Harald
2018-11-01 09:15:14 UTC
Permalink
Post by piliu
I encounter an issue during the poweroff. In my bash script, firstly I
use poweroff cmd to start systemd-poweroff.service, and use reboot cmd
as a bake up if the poweroff fails. But during tests, many times, the
machine is rebooted directly, without waiting for the result of poweroff.
Since both of the cmds use "systemctl" without --no-block option, so I
think they should execute one-by-one. But the test result is not.
Any suggestion?
just don't do that!

when power-off fails reboot would fail too and so that all makes no
sense - the only differnece between reboot and power off is the action
after OS shutdown
Andrei Borzenkov
2018-11-01 09:52:51 UTC
Permalink
Post by piliu
Hi,
I encounter an issue during the poweroff. In my bash script, firstly I
use poweroff cmd to start systemd-poweroff.service, and use reboot cmd
as a bake up if the poweroff fails. But during tests, many times, the
machine is rebooted directly, without waiting for the result of poweroff.
Since both of the cmds use "systemctl" without --no-block option, so I
think they should execute one-by-one. But the test result is not.
Any suggestion?
Most likely your systemctl is killed during shutdown processing (which
is implicitly initiated by systemd-poweroff.service).
piliu
2018-11-05 06:17:32 UTC
Permalink
Post by Andrei Borzenkov
Post by piliu
Hi,
I encounter an issue during the poweroff. In my bash script, firstly I
use poweroff cmd to start systemd-poweroff.service, and use reboot cmd
as a bake up if the poweroff fails. But during tests, many times, the
machine is rebooted directly, without waiting for the result of poweroff.
Since both of the cmds use "systemctl" without --no-block option, so I
think they should execute one-by-one. But the test result is not.
Any suggestion?
Most likely your systemctl is killed during shutdown processing (which
is implicitly initiated by systemd-poweroff.service).
During this service, the power state can not be got from sysfs, neither
it can be got by systemd's utility. So is it acceptable to signal the
failure of service by a tmp file under /tmp ? I.e adding
FailureAction=touch /tmp/poweroff_fail in systemd-poweroff.service.

Thanks,
Pingfan
Cristian Rodríguez
2018-11-06 12:12:00 UTC
Permalink
Post by piliu
During this service, the power state can not be got from sysfs, neither
it can be got by systemd's utility. So is it acceptable to signal the
failure of service by a tmp file under /tmp ? I.e adding
FailureAction=touch /tmp/poweroff_fail in systemd-poweroff.service.
No, that will likely race too.. please focus on why you think you need
this contrieved,hackish solution.

If as you say in your other message, if you start just one operation,
either reboot or poweroff but not both it will be ok.

Cristian Rodríguez
2018-11-05 11:42:26 UTC
Permalink
Post by piliu
Any suggestion?
Yeah. Don't..if poweroff fails reboot will too..please attack the root
cause of this problem.. why the machine fails to poweroff, is it a
service blocking poweroff ? is there a kernel bug ?
piliu
2018-11-06 05:23:15 UTC
Permalink
Post by Cristian Rodríguez
Post by piliu
Any suggestion?
Yeah. Don't..if poweroff fails reboot will too..please attack the root
cause of this problem.. why the machine fails to poweroff, is it a
service blocking poweroff ? is there a kernel bug ?
No, it is not kernel bug. Our kdump script always uses reboot as a
back-end method. And if in kdump.conf, choosing poweroff as default
action, then there is the race sequence poweroff -> reboot.
Maybe the script should not launch reboot-service if it already launched
a poweroff service
Post by Cristian Rodríguez
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
Continue reading on narkive:
Loading...