Subject: Re: bug#77373: [shepherd] Deadlock between service-controller and service-builtin-logger

From: Ludovic Courtès <[email-masked]>
Date: Sun, 30 Mar 2025 18:44:50 +0200

Hey,

nathan <[email-masked]> skribis:

> happy sunday
>
>> Yes, but only if ‘pid’ hasn’t been cached before, which I think would
>> mean that not a single line was logged before stopping the service.
>
> doesn't get cached if no output is read while service is 'running.
> fork+exec-command: if the pid-file doesnt show up immediately, there is an entire 1 second sleep. The logger can easily read the output while the service is still in 'starting
> also: if the service doesn't flush stdout, we dont get its output until it dies. ('stopping)
>
>> Could you explain exactly how that happens (sequence of actions leading
>> to the deadlock) and share the relevant /var/log/messages excerpt?
>
> ./shepherd --socket /tmp/s2/mysocket --config <path>

Yup, I see.

I believe a5d9a41aa0bfadea9617df4411b86c6ea0c525bd fixes it.  I added a
test case that’s similar to what you have: the service only starts
logging when being stopped, which makes it very likely that the logger
will receive lines of log after the service has terminated.  It would
trigger the deadlock 100% of the time.

Let me know what you think.

Thanks a lot!

Ludo’.