[systemd-devel] Services with multiple pre-requisites

Lennart Poettering lennart at poettering.net
Tue Dec 22 14:04:00 UTC 2020


On Di, 22.12.20 13:18, freedesktop at priatel.co.uk (freedesktop at priatel.co.uk) wrote:

> Andrei Borzenkov wrote:
> >> It has noticed and logged that one of the Requisite targets for the
> >> Third service isn't active, but it starts it anyway :-(
> >>
> >> That seems to go directly against the documented behaviour (at
> >> https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Req
> >> uisite
> >> =):
> >>   | Requisite=
> >>   |
> >>   |     Similar to Requires=. However, if the units listed here are not
> >>   |     started already, they will not be started and the starting of
> >>   |     this unit will fail immediately.
> >>
> >> Is this a bug, or am I still missing something?
> >
> > You miss ordering dependencies. Neither Requires not Requisite work without proper
> > After/Before.
> >
> > systemd manuals make impression that dependencies are between units.
> > This is wrong - dependencies are between jobs. If unit B has "Requisite:
> > A" what happens is - systemd implicitly creates job for unit A that
> > verifies current state of unit A and if it is not active fails pending
> > start job for unit B. Without proper ordering both jobs (verify state of
> > unit A and start unit B) run concurrently and the order is
> > non-deterministic (or may be it is but then it is always "wrong" for
> > your purpose :) ), so in your case job for Second runs too late, when
> > Third is already started and there is no pending job to fail.
>
> Ah. Thanks for the explanation. Adding
>   Wants=first.target second.target

Hmm, what?

After=/Before= are the ordering deps, Wants= is a requirement dep.

> Respectfully suggest that the documentation bug should be fixed!

I am sorry, what?

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list