[systemd-devel] Services with multiple pre-requisites

freedesktop at priatel.co.uk freedesktop at priatel.co.uk
Tue Dec 22 13:18:46 UTC 2020


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
to my 'Third service' gave me exactly the behaviour I needed.

Respectfully suggest that the documentation bug should be fixed!

Martin



More information about the systemd-devel mailing list