<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>I think the temperature-controller.service is stopped due to the Before=<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">temperature-controller.service</span>
 in coco-wiper-manager.service.</p>
<p><br>
</p>
<p>There are no BindsTo=</p>
<p>The Conflicts=shutdown.target only.</p>
<p><br>
</p>
<p>I will do some more investigations after New Year.</p>
<p><br>
</p>
<p>Thank you for your time and explanations!</p>
<p><br>
</p>
<p>Merry X'mas and Happy New Year!</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
Christopher Wong
<div><br>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Anita Zhang <the.anitazha@gmail.com><br>
<b>Sent:</b> Thursday, December 23, 2021 9:21:48 AM<br>
<b>To:</b> Christopher Wong<br>
<b>Cc:</b> systemd-devel@lists.freedesktop.org<br>
<b>Subject:</b> Re: [systemd-devel] After= and Wants= doesn't seem to have an effect</font>
<div> </div>
</div>
<div>
<div dir="ltr">I think the telling part is "temperature-controller.service/start finished, result=canceled". When another job for the same unit comes in (e.g. "temperature-controller.service: Trying to enqueue job temperature-controller.service/stop/replace")
 then the first job gets canceled and replaced by the new one (this is the default behavior which I think can be overridden). The bad part is systemd doesn't have logs to tell you why the stop transaction was issued. Maybe you can use `systemctl show temperature-controller.service`
 to see if there are BindsTo= or Conflicts= dependencies that are not listed in the unit files and causing the stop job to get issued.<br>
<div><br>
</div>
<div>As for your other point about why opticsd.service runs after temperature-controller.service's stop job, I think this is by design. According to <a href="https://github.com/systemd/systemd/blob/4d484e14bb9864cef1d124885e625f33bf31e91c/src/core/job.c#L1659-L1698">https://github.com/systemd/systemd/blob/4d484e14bb9864cef1d124885e625f33bf31e91c/src/core/job.c#L1659-L1698</a>
 if  "b" starts after "a", but "a" has a stop job queued, then "a" will stop, then "b" will start. Substitute opticsd for "b" and temperature-controller for "a". The Wants= property issued a start job so what you're expecting is "a" starts, then "b" starts.
 But due to the canceled job mentioned above, you're instead left with "a" stops, then "b" starts.</div>
<div><br>
</div>
<div>Hope that helps,</div>
<div>Anita</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Dec 22, 2021 at 10:15 AM Christopher Wong <<a href="mailto:Christopher.Wong@axis.com">Christopher.Wong@axis.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div dir="ltr">
<div id="gmail-m_-2225924481517916404x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p>The code is being run on systemd 247.6. I finally got some debug logs to share (see below). The starting of opticsd.service is held back, waiting for temperature-controller.service, which is good. However, the line right after: Job 721, which is a stop job
 for temperature-controller finished with result=done. That seems to trigger the continuation of opticsd.service. I don't have the logs for when Job 107 was started and why Job 721 is created. My guess is that temperature-controller is waiting for coco-wiper-manager
 as indicated in Job 722 and Job 809. Could this really be a bug and I am that lucky to stumble into it?</p>
<p><br>
</p>
<p></p>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Got message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=StopUnit cookie=1 reply_cookie=0 signature=ss error-name=n/a
 error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Trying to enqueue job temperature-controller.service/stop/replace</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Added job temperature-controller.service/stop to transaction.</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Job 107 temperature-controller.service/start finished, result=canceled</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=1 reply_cookie=0 signature=uoss error-name=n/a
 error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Installed new job temperature-controller.service/stop as 721</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Enqueued job temperature-controller.service/stop as 721</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/temperature_2dcontroller_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged
 cookie=2 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/temperature_2dcontroller_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged
 cookie=3 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobNew cookie=4 reply_cookie=0 signature=uos error-name=n/a
 error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=5 reply_cookie=1 signature=o error-name=n/a error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: opticsd.service: starting held back, waiting for: temperature-controller.service</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Job 721 temperature-controller.service/stop finished, result=done</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=6 reply_cookie=0 signature=uoss error-name=n/a
 error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Failed to read pids.max attribute of cgroup root, ignoring: No data available</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: opticsd.service: Forked /usr/bin/udevadm as 561</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/opticsd_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=7 reply_cookie=0
 signature=sa{sv}as error-name=n/a error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/opticsd_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0
 signature=sa{sv}as error-name=n/a error-message=n/a</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: opticsd.service: Changed dead -> start-pre</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Starting Optics daemon...</div>
...
<p></p>
<p><br>
</p>
<p></p>
<div></div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Keeping job coco-wiper-manager.service/start because of temperature-controller.service/start</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Installed new job temperature-controller.service/start as 722</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Enqueued job temperature-controller.service/start as 722</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: starting held back, waiting for: coco-wiper-manager.service</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Trying to enqueue job temperature-controller.service/stop/replace</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: Added job temperature-controller.service/stop to transaction.</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Job 722 temperature-controller.service/start finished, result=canceled</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Installed new job temperature-controller.service/stop as 809</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Enqueued job temperature-controller.service/stop as 809</div>
<div>Dec 22 18:03:17 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Job 809 temperature-controller.service/stop finished, result=done</div>
<div>Dec 22 18:03:18 axis-b8a44f278c56 systemd[1]: temperature-controller.service: Trying to enqueue job temperature-controller.service/start/replace</div>
<p></p>
<p><br>
</p>
<p>Best Regards,</p>
<div id="gmail-m_-2225924481517916404x_Signature">
<div name="x_divtagdefaultwrapper">Christopher Wong
<div><br>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-2225924481517916404x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com" target="_blank">arvidjaar@gmail.com</a>><br>
<b>Sent:</b> Tuesday, December 21, 2021 8:24:35 AM<br>
<b>To:</b> Christopher Wong; <a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">
systemd-devel@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [systemd-devel] After= and Wants= doesn't seem to have an effect</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div>On 20.12.2021 17:05, Christopher Wong wrote:<br>
>> # /etc/systemd/system/iris-detection.service<br>
>> [Unit]<br>
>> Description=Iris detection<br>
>> PartOf=opticsd.service<br>
> <br>
> <br>
> How can you tell that it is a loop? iris-detection.service doesn't have any After= as you stated below.<br>
<br>
Yes, sorry, you are right.<br>
<br>
> Is it due to the PartOf=opticsd.service?<br>
> <br>
<br>
I do not think so. Still, loop is possible due to some other dependencies, it is also<br>
possible that actual unit definitions are different (e.g. units files have been changed<br>
after systemd read them).<br>
<br>
Running with debig log level may give some more hints.<br>
<br>
> <br>
> Best Regards,<br>
> <br>
> Christopher Wong<br>
> <br>
> ________________________________<br>
> From: systemd-devel <<a href="mailto:systemd-devel-bounces@lists.freedesktop.org" target="_blank">systemd-devel-bounces@lists.freedesktop.org</a>> on behalf of Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com" target="_blank">arvidjaar@gmail.com</a>><br>
> Sent: Monday, December 20, 2021 1:27:42 PM<br>
> To: <a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
> Subject: Re: [systemd-devel] After= and Wants= doesn't seem to have an effect<br>
> <br>
> On 20.12.2021 15:06, Christopher Wong wrote:<br>
>> # /etc/systemd/system/iris-detection.service<br>
>> After=temperature-controller.service<br>
>><br>
>> # /usr/lib/systemd/system/temperature-controller.service<br>
>> After=iris-detection.service<br>
> <br>
> This is loop and systemd is free to break it by ignoring some dependency.<br>
> <br>
<br>
</div>
</span></font></div>
</blockquote>
</div>
</div>
</body>
</html>