otp icon indicating copy to clipboard operation
otp copied to clipboard

Add Supervisor shutdown options

Open nerdyworm opened this issue 1 year ago • 1 comments
trafficstars

The original issue that I was facing was that supervisors never actually killed their child processes, thus leading to a memory/process leak when my system was running for about a week.

This pull request implements the two strategies that erlang's supervisor employees, timeout and brutal kill.

The root cause of why actors never exit with erlang:exit(pid, normal) is still unknown.

nerdyworm avatar Jun 06 '24 14:06 nerdyworm

Update: I discovered that using erlang:exit(Pid, normal) from an external process does not stop the process.

I've updated my PR to use erlang:exit(Pid, shutdown). This successfully stops the actors and everything looks perfect.

I've also discovered if your actor traps exits, then you'll have to match on the following in your actor to shut it down, otherwise, it will timeout -> brutal kill.

 Down(ExitMessage(_supervisor_pid, Abnormal("Shutdown"))) -> {
      actor.Stop(Abnormal("shutdown"))
  }

nerdyworm avatar Jun 07 '24 14:06 nerdyworm

Closing due to inactivity. Please feel free to open again. Thank you

lpil avatar May 06 '25 17:05 lpil