systemd / systemd

The systemd System and Service Manager
https://systemd.io
GNU General Public License v2.0
13.02k stars 3.73k forks source link

Documentation: Semantics of timer expiry isn't well documented #10626

Open nh2 opened 5 years ago

nh2 commented 5 years ago

The systemd.timer man page currently does not describe important aspects of timer semantics, which can lead to unexpected/unintended/wrong behaviour when used and be very frustrating.

I'll first show an example problem, and then ask some concrete questions that I couldn't answer from the current documentation.

Example problem

When I systemctl stop a.service, I often get the output Job for a.service canceled.

After some investigation and lots of great help from boucman on IRC, we tracked it down to a timer b.timer + b.service, where b.service is Requires=/After= on a.service.

The timer is set to OnUnitActiveSec=1m; the started service itself can take longer than a minute to complete its task. We observe that:

When investigating whether this is as expected, the problem here is that nobody seems to really understand when timers fire, and that the documentation leaves these things open. Thus:

Things to be documented

After these questions are cleared, we'd like to document these semantics in the systemd.timers man page.

nh2 commented 5 years ago

CC @arianvp

nh2 commented 5 years ago

I forgot to say: The Job for a.service canceled happens most of the time, but not all the time, so there seems to be some race in it.

nh2 commented 5 years ago

Putting in some more details as asked on IRC:

flokli commented 4 years ago

This is effectively preventing switching configuration / restarting reliably.

Some context: https://github.com/NixOS/nixpkgs/issues/49415#issuecomment-435611241

cdn-rsync.timer/ cdn-rsync.service, pulls in consul.service, and effectively prevents consul.service from being restarted.