-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Supervisor shutdown options #65
base: main
Are you sure you want to change the base?
Conversation
Update: I discovered that using I've updated my PR to use 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"))
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wonderful! Thank you for digging into this! 💜
Looks great, though I've left some small notes inline.
ChildSpec(..child, shutdown: Timeout(timeout)) | ||
} | ||
|
||
pub fn shutdown_brutal_kill( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this function for? It is undocumented.
ChildSpec(start: child.start, returning: updater, shutdown: child.shutdown) | ||
} | ||
|
||
/// Change the shutdown timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add more documentation here please 🙏
let result = | ||
process.new_selector() | ||
|> process.selecting_anything(fn(a) { a }) | ||
|> process.select(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This drops the first message in the inbox, but this may not be the exit message. It needs to drop specifically the expected message here.
// Ensure that the original processes are dead | ||
should.be_false(process.is_alive(pid1)) | ||
should.be_false(process.is_alive(pid2)) | ||
should.be_false(process.is_alive(pid3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move these to a new test please 🙏
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.