Gracefully handle receipt of multiple termination signals#207
Merged
mperham merged 1 commit intosidekiq:masterfrom May 21, 2012
dazuma:prevent-multiple-signals
Merged
Gracefully handle receipt of multiple termination signals#207mperham merged 1 commit intosidekiq:masterfrom dazuma:prevent-multiple-signals
mperham merged 1 commit intosidekiq:masterfrom
dazuma:prevent-multiple-signals
Conversation
mperham
added a commit
that referenced
this pull request
May 21, 2012
Gracefully handle receipt of multiple termination signals
Collaborator
|
Awesome fix, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for an issue I came across yesterday when deploying a sidekiq worker as a daemon.
The issue is that when you send a SIGTERM or SIGINT to a running worker, it initiates shutdown by raising an Interrupt in the main thread. The shutdown process takes a finite amount of time because it waits for the manager to shut down, and then Celluloid registers an at_exit process that does its own cleanup of running actors. If another signal is received during that cleanup process, the cleanup itself is interrupted by an exception, and this causes the whole system to go crazy. In my case, the second signal was received during Celluloid's at_exit cleanup, and, on Mac OS Lion, this (for reasons I don't care to understand fully) caused the process to spin at 100% cpu until you kill -9 it.
This patch simply ensures that at most one Interrupt exception is raised as a result of receiving a termination signal.