Subject: bug#76338: shepherd restarts service during shutdown and then waits forever

From: Dariqq <[email-masked]>
Date: Mon, 17 Feb 2025 10:15:53 +0000

Hi Ludo,

On 16.02.25 18:23, Ludovic Courtès wrote:
> Hi,
> 
> Dariqq <[email-masked]> skribis:
> 
>> The issue is that thermald (and possibly other services) don't depend
>> on user-processes service. Don't know why I had no problems until now.
> 
> This should be fixed: they should all depend on ‘user-processes’.
> 
For the record I will not be verifying every daemon service manually in 
the guix codebase whether it correctly depends on user-processes. Many 
do directly however also a lot only do transitively. The problematic 
cases most likely are where a service sets no requirement field at all

The two services that I know of are thermald and virtlogd.

Also the purpose of the user-processes service (and maybe also the 
filesystems) service as synchronization targets are documented only in 
their definition and implicitly with the shepherd graph image. 
System-shepherd services that dont depend on anything are probably a bad 
idea and seems like a very common mistake for (new) users implementing 
their own services.
Maybe this should be a a more explicit note in the documentation for 
shepherd-service-requirement and/or a small paragraph in the shepherd 
services intro?

> Probably the bug you’re seeing here was revealed by
> <https://issues.guix.gnu.org/75829>.
> 

Is there a reason for user-processes to block on waiting for every 
process execpt PID1 to exit or why during the (sleep 1) calls other 
services (that falsely dont depend on user-processes) are not being 
stopped in the meantime which would help resolve the deadlock?

This causes every daemon indirectly to depend on user-processes but 
shepherd may not know about it.

> But perhaps shepherd should also just disable all services when shutting
> down so that respawning doesn’t happen.

I guess shepherd is just doing its duty as a service manager. Something 
else send SIGTERM/SIGKILL and shepherd kindly respawns it as instructed.
But insisting on restarting a service seems a bit pointless to me during 
shutdown/reboot where everything will be terminated anyway.

> Ludo’.