{"action":"created","comment":{"url":"https://api.github.com/repos/camilo/unicorn/pulls/comments/70488934","id":70488934,"diff_hunk":"@@ -475,7 +478,10 @@ def murder_lazy_workers\n       next_sleep = 0\n       logger.error \"worker=#{worker.nr} PID:#{wpid} timeout \" \\\n                    \"(#{diff}s > #{@timeout}s), killing\"\n-      before_murder.call(self, worker, wpid) if before_murder\n+      if before_murder and not @before_murder_called.include?(wpid)","path":"lib/unicorn/http_server.rb","position":27,"original_position":27,"commit_id":"81c9c6f7199db495fa08274f25b9cec29e066cc8","original_commit_id":"81c9c6f7199db495fa08274f25b9cec29e066cc8","user":{"login":"fbogsany","id":1551119,"avatar_url":"https://avatars.githubusercontent.com/u/1551119?v=3","gravatar_id":"","url":"https://api.github.com/users/fbogsany","html_url":"https://github.com/fbogsany","followers_url":"https://api.github.com/users/fbogsany/followers","following_url":"https://api.github.com/users/fbogsany/following{/other_user}","gists_url":"https://api.github.com/users/fbogsany/gists{/gist_id}","starred_url":"https://api.github.com/users/fbogsany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fbogsany/subscriptions","organizations_url":"https://api.github.com/users/fbogsany/orgs","repos_url":"https://api.github.com/users/fbogsany/repos","events_url":"https://api.github.com/users/fbogsany/events{/privacy}","received_events_url":"https://api.github.com/users/fbogsany/received_events","type":"User","site_admin":false},"body":"We prefer `&& !` instead of `and not` here. Use of the english operators should be restricted to control flow (like the Perl-ism: `do_this or die`).","created_at":"2016-07-12T18:02:28Z","updated_at":"2016-07-12T18:02:28Z","html_url":"https://github.com/camilo/unicorn/pull/5#discussion_r70488934","pull_request_url":"https://api.github.com/repos/camilo/unicorn/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/comments/70488934"},"html":{"href":"https://github.com/camilo/unicorn/pull/5#discussion_r70488934"},"pull_request":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/camilo/unicorn/pulls/5","id":76172596,"html_url":"https://github.com/camilo/unicorn/pull/5","diff_url":"https://github.com/camilo/unicorn/pull/5.diff","patch_url":"https://github.com/camilo/unicorn/pull/5.patch","issue_url":"https://api.github.com/repos/camilo/unicorn/issues/5","number":5,"state":"open","locked":false,"title":"ensure before murder is called only once","user":{"login":"shivnagarajan","id":11840428,"avatar_url":"https://avatars.githubusercontent.com/u/11840428?v=3","gravatar_id":"","url":"https://api.github.com/users/shivnagarajan","html_url":"https://github.com/shivnagarajan","followers_url":"https://api.github.com/users/shivnagarajan/followers","following_url":"https://api.github.com/users/shivnagarajan/following{/other_user}","gists_url":"https://api.github.com/users/shivnagarajan/gists{/gist_id}","starred_url":"https://api.github.com/users/shivnagarajan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivnagarajan/subscriptions","organizations_url":"https://api.github.com/users/shivnagarajan/orgs","repos_url":"https://api.github.com/users/shivnagarajan/repos","events_url":"https://api.github.com/users/shivnagarajan/events{/privacy}","received_events_url":"https://api.github.com/users/shivnagarajan/received_events","type":"User","site_admin":false},"body":"it turns out that it is possible for unicorn to call before_murder more than once for the same worker that it is trying to kill. This specifically happens when it loops around finding things to kill, and decides it needs to kill a worker. It sends it a SIGKILL, and then continues around its loop. Eventually it finishes this loop and return to its main loop from where it could be woken up immediately. It tries to reap_workers which calls waitpid2 with a NOHANG flag. Since a waitpid status is available only _after_ a process is completely terminated, it is very likely that the process is still around, and we would call before_murder again. \r\n\r\nThis change ensure that does not happen. It primarily prevents the before_murder from being called multiple times, but I could also wrap the entire `before_murder .. kill_worker` so we don't log, call before_murder or call kill_worker multiple times.\r\n\r\nThere are many cases we are sending a kill to the same process more than once, and as a result we also call before_murder as many times.\r\n\r\n@camilo \r\n","created_at":"2016-07-04T14:36:07Z","updated_at":"2016-07-12T18:02:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bb22cf3c221f315c9615404af86b97b03525096","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/camilo/unicorn/pulls/5/commits","review_comments_url":"https://api.github.com/repos/camilo/unicorn/pulls/5/comments","review_comment_url":"https://api.github.com/repos/camilo/unicorn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/camilo/unicorn/issues/5/comments","statuses_url":"https://api.github.com/repos/camilo/unicorn/statuses/81c9c6f7199db495fa08274f25b9cec29e066cc8","head":{"label":"Shopify:before_murder_only_once","ref":"before_murder_only_once","sha":"81c9c6f7199db495fa08274f25b9cec29e066cc8","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":35685933,"name":"unicorn","full_name":"Shopify/unicorn","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/unicorn","description":"Copy of unicorn webserver","fork":true,"url":"https://api.github.com/repos/Shopify/unicorn","forks_url":"https://api.github.com/repos/Shopify/unicorn/forks","keys_url":"https://api.github.com/repos/Shopify/unicorn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/unicorn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/unicorn/teams","hooks_url":"https://api.github.com/repos/Shopify/unicorn/hooks","issue_events_url":"https://api.github.com/repos/Shopify/unicorn/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/unicorn/events","assignees_url":"https://api.github.com/repos/Shopify/unicorn/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/unicorn/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/unicorn/tags","blobs_url":"https://api.github.com/repos/Shopify/unicorn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/unicorn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/unicorn/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/unicorn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/unicorn/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/unicorn/languages","stargazers_url":"https://api.github.com/repos/Shopify/unicorn/stargazers","contributors_url":"https://api.github.com/repos/Shopify/unicorn/contributors","subscribers_url":"https://api.github.com/repos/Shopify/unicorn/subscribers","subscription_url":"https://api.github.com/repos/Shopify/unicorn/subscription","commits_url":"https://api.github.com/repos/Shopify/unicorn/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/unicorn/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/unicorn/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/unicorn/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/unicorn/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/unicorn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/unicorn/merges","archive_url":"https://api.github.com/repos/Shopify/unicorn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/unicorn/downloads","issues_url":"https://api.github.com/repos/Shopify/unicorn/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/unicorn/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/unicorn/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/unicorn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/unicorn/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/unicorn/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/unicorn/deployments","created_at":"2015-05-15T17:00:03Z","updated_at":"2015-05-15T17:00:05Z","pushed_at":"2016-07-12T14:26:06Z","git_url":"git://github.com/Shopify/unicorn.git","ssh_url":"git@github.com:Shopify/unicorn.git","clone_url":"https://github.com/Shopify/unicorn.git","svn_url":"https://github.com/Shopify/unicorn","homepage":null,"size":5765,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"camilo:master","ref":"master","sha":"b32c1ea0a6c1403c35ca4421006ac2530c62ade2","user":{"login":"camilo","id":7748,"avatar_url":"https://avatars.githubusercontent.com/u/7748?v=3","gravatar_id":"","url":"https://api.github.com/users/camilo","html_url":"https://github.com/camilo","followers_url":"https://api.github.com/users/camilo/followers","following_url":"https://api.github.com/users/camilo/following{/other_user}","gists_url":"https://api.github.com/users/camilo/gists{/gist_id}","starred_url":"https://api.github.com/users/camilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camilo/subscriptions","organizations_url":"https://api.github.com/users/camilo/orgs","repos_url":"https://api.github.com/users/camilo/repos","events_url":"https://api.github.com/users/camilo/events{/privacy}","received_events_url":"https://api.github.com/users/camilo/received_events","type":"User","site_admin":false},"repo":{"id":18450181,"name":"unicorn","full_name":"camilo/unicorn","owner":{"login":"camilo","id":7748,"avatar_url":"https://avatars.githubusercontent.com/u/7748?v=3","gravatar_id":"","url":"https://api.github.com/users/camilo","html_url":"https://github.com/camilo","followers_url":"https://api.github.com/users/camilo/followers","following_url":"https://api.github.com/users/camilo/following{/other_user}","gists_url":"https://api.github.com/users/camilo/gists{/gist_id}","starred_url":"https://api.github.com/users/camilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/camilo/subscriptions","organizations_url":"https://api.github.com/users/camilo/orgs","repos_url":"https://api.github.com/users/camilo/repos","events_url":"https://api.github.com/users/camilo/events{/privacy}","received_events_url":"https://api.github.com/users/camilo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/camilo/unicorn","description":"Copy of unicorn webserver","fork":false,"url":"https://api.github.com/repos/camilo/unicorn","forks_url":"https://api.github.com/repos/camilo/unicorn/forks","keys_url":"https://api.github.com/repos/camilo/unicorn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/camilo/unicorn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/camilo/unicorn/teams","hooks_url":"https://api.github.com/repos/camilo/unicorn/hooks","issue_events_url":"https://api.github.com/repos/camilo/unicorn/issues/events{/number}","events_url":"https://api.github.com/repos/camilo/unicorn/events","assignees_url":"https://api.github.com/repos/camilo/unicorn/assignees{/user}","branches_url":"https://api.github.com/repos/camilo/unicorn/branches{/branch}","tags_url":"https://api.github.com/repos/camilo/unicorn/tags","blobs_url":"https://api.github.com/repos/camilo/unicorn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/camilo/unicorn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/camilo/unicorn/git/refs{/sha}","trees_url":"https://api.github.com/repos/camilo/unicorn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/camilo/unicorn/statuses/{sha}","languages_url":"https://api.github.com/repos/camilo/unicorn/languages","stargazers_url":"https://api.github.com/repos/camilo/unicorn/stargazers","contributors_url":"https://api.github.com/repos/camilo/unicorn/contributors","subscribers_url":"https://api.github.com/repos/camilo/unicorn/subscribers","subscription_url":"https://api.github.com/repos/camilo/unicorn/subscription","commits_url":"https://api.github.com/repos/camilo/unicorn/commits{/sha}","git_commits_url":"https://api.github.com/repos/camilo/unicorn/git/commits{/sha}","comments_url":"https://api.github.com/repos/camilo/unicorn/comments{/number}","issue_comment_url":"https://api.github.com/repos/camilo/unicorn/issues/comments{/number}","contents_url":"https://api.github.com/repos/camilo/unicorn/contents/{+path}","compare_url":"https://api.github.com/repos/camilo/unicorn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/camilo/unicorn/merges","archive_url":"https://api.github.com/repos/camilo/unicorn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/camilo/unicorn/downloads","issues_url":"https://api.github.com/repos/camilo/unicorn/issues{/number}","pulls_url":"https://api.github.com/repos/camilo/unicorn/pulls{/number}","milestones_url":"https://api.github.com/repos/camilo/unicorn/milestones{/number}","notifications_url":"https://api.github.com/repos/camilo/unicorn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/camilo/unicorn/labels{/name}","releases_url":"https://api.github.com/repos/camilo/unicorn/releases{/id}","deployments_url":"https://api.github.com/repos/camilo/unicorn/deployments","created_at":"2014-04-04T19:33:30Z","updated_at":"2014-11-07T20:18:15Z","pushed_at":"2016-07-12T14:26:07Z","git_url":"git://github.com/camilo/unicorn.git","ssh_url":"git@github.com:camilo/unicorn.git","clone_url":"https://github.com/camilo/unicorn.git","svn_url":"https://github.com/camilo/unicorn","homepage":null,"size":6143,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/5"},"html":{"href":"https://github.com/camilo/unicorn/pull/5"},"issue":{"href":"https://api.github.com/repos/camilo/unicorn/issues/5"},"comments":{"href":"https://api.github.com/repos/camilo/unicorn/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/camilo/unicorn/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/camilo/unicorn/statuses/81c9c6f7199db495fa08274f25b9cec29e066cc8"}}}}
{"actor":{"display_login":"fbogsany"}}