[systemd-devel] systemd-journald, syslog.socket and service activation

Thomas HUMMEL thomas.hummel at pasteur.fr
Fri Jul 3 09:09:40 UTC 2020



On 02/07/2020 20:48, Andrei Borzenkov wrote:


> Once again - dependencies in systemd are between jobs, not between units.

Ok. I may have missed some docs but I've read several man sections 
(likesystemd.service(5) and so on) as well as some 0pointer blog 
articles) and I did experiment a lot.
I did not see this explained as clearly as you do here. At the opposite 
it tends to focus on units (at least that's how I've read it the first 
time), hence the confusion ? In fact, when reading those for the first 
time I was left wanting to know more about transactions and jobs (which 
are mentioned but really quickly). [Note that this is by no way a 
criticism, just a/my feedback]. Watching debug logs gave me hints but 
were not sufficient to come to the understanding you give me right now.

> Rule 1: "B requires A" means "when starting B also submit start job for
> A and if this job failed *before we start activating B* cancel
> activation of B". If there is already start job for A for other reasons,
> the first part does nothing.

Ok. What could be other reasons and do you mean this other reason would 
itself have already added the A dependency and its management for itself ?

> 
> Rule 2: "B after A" means "if start job for A is present in job queue
> wait for this job to complete before proceeding with start job for B".
> 
> In your case on boot you have general Before dependency syslog.socket -
> sockets.target - basic.target - rsyslog.service and start request for
> both syslog.socket and rsyslog.service are queued. Start job for
> rsyslog.service is always delayed at least after basic.target (rule 2).
> At this point systemd already tried and failed to start syslog.socket,
> so rule 1 applies.

Ok. So I guess my test when I, after reboot, run 4 ou 5 systemctl start 
rsyslog.service and only the last one succeeds corresponds to this "race 
condition" you described above ?

Thanks a lot for your explanations. Makes more sense now.

--
Thomas HUMMEL


More information about the systemd-devel mailing list