thejerf / suture

Supervisor trees for Go.
MIT License
1.32k stars 74 forks source link

Deadlock calling Supervisor.Add when stopping/stopped #41

Closed imsodin closed 3 years ago

imsodin commented 4 years ago

I came across the issue while implementing v4, but looking at the code it applies to <v4 as well: When calling Add while the supervisor is in progress of stopping or has already stopped, it will block forever on trying to send to s.control. I couldn't find any specification of the behaviour when calling Add on a stopped supervisor. Even if this wasn't allowed, the deadlock could still happen due to a race between stopping and adding a service. A solution could be to use sendControl and make .Add a noop on a stopped supervisor.

thejerf commented 4 years ago

Thank you, I will make it safe.

It is certainly not a "supported feature", for obvious reasons, but there's no reason to be deadlocking on it.

imsodin commented 3 years ago

Fixed by https://github.com/thejerf/suture/pull/43.