{"action":"created","comment":{"url":"https://api.github.com/repos/OptimalBits/bull/pulls/comments/63627886","id":63627886,"diff_hunk":"@@ -505,7 +505,14 @@ Queue.prototype.processStalledJob = function(job){\n           if(!isMember){\n             _this.emit('stalled', job);\n             return _this.processJob(job, true);\n+          } else {\n+            return job.releaseLock(_this.token);\n           }\n+        }).catch(function(err) {\n+          // Any uncaught error will come here. We'll ensure that the job lock is released and rethrow\n+          // the error so it bubbles normally\n+          job.releaseLock(_this.token);\n+          throw err;\n         });","path":"lib/queue.js","position":12,"original_position":12,"commit_id":"9c70c24d3094958cea5f0ea20fde3fbe88a7790a","original_commit_id":"9c70c24d3094958cea5f0ea20fde3fbe88a7790a","user":{"login":"chuym","id":554933,"avatar_url":"https://avatars.githubusercontent.com/u/554933?v=3","gravatar_id":"","url":"https://api.github.com/users/chuym","html_url":"https://github.com/chuym","followers_url":"https://api.github.com/users/chuym/followers","following_url":"https://api.github.com/users/chuym/following{/other_user}","gists_url":"https://api.github.com/users/chuym/gists{/gist_id}","starred_url":"https://api.github.com/users/chuym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuym/subscriptions","organizations_url":"https://api.github.com/users/chuym/orgs","repos_url":"https://api.github.com/users/chuym/repos","events_url":"https://api.github.com/users/chuym/events{/privacy}","received_events_url":"https://api.github.com/users/chuym/received_events","type":"User","site_admin":false},"body":"I thought about using finally, but then I realized If we release an already released lock, we could  inadvertently release it for a resource that took the lock lawfully. With finally we are in a situation where we release the lock _at least once_, but with catch, we ensure that the lock is released _exactly once_ thus not running the risk of releasing the lock for some other consumer.","created_at":"2016-05-18T00:26:27Z","updated_at":"2016-05-18T00:26:27Z","html_url":"https://github.com/OptimalBits/bull/pull/300#discussion_r63627886","pull_request_url":"https://api.github.com/repos/OptimalBits/bull/pulls/300","_links":{"self":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/comments/63627886"},"html":{"href":"https://github.com/OptimalBits/bull/pull/300#discussion_r63627886"},"pull_request":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/300"}}},"pull_request":{"url":"https://api.github.com/repos/OptimalBits/bull/pulls/300","id":70274274,"html_url":"https://github.com/OptimalBits/bull/pull/300","diff_url":"https://github.com/OptimalBits/bull/pull/300.diff","patch_url":"https://github.com/OptimalBits/bull/pull/300.patch","issue_url":"https://api.github.com/repos/OptimalBits/bull/issues/300","number":300,"state":"open","locked":false,"title":"Releasing lock from processStalledJobs","user":{"login":"chuym","id":554933,"avatar_url":"https://avatars.githubusercontent.com/u/554933?v=3","gravatar_id":"","url":"https://api.github.com/users/chuym","html_url":"https://github.com/chuym","followers_url":"https://api.github.com/users/chuym/followers","following_url":"https://api.github.com/users/chuym/following{/other_user}","gists_url":"https://api.github.com/users/chuym/gists{/gist_id}","starred_url":"https://api.github.com/users/chuym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuym/subscriptions","organizations_url":"https://api.github.com/users/chuym/orgs","repos_url":"https://api.github.com/users/chuym/repos","events_url":"https://api.github.com/users/chuym/events{/privacy}","received_events_url":"https://api.github.com/users/chuym/received_events","type":"User","site_admin":false},"body":"Currently, `Queue#processStalledJobs` can run into a state where it locks a `completed` job and doesn't unlock when it does the check to see if the job is `completed` by the time it actually attempts to process it.","created_at":"2016-05-16T22:45:56Z","updated_at":"2016-05-18T00:26:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1055aa5ddf3ba72b4175a2585413a80928b916fa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OptimalBits/bull/pulls/300/commits","review_comments_url":"https://api.github.com/repos/OptimalBits/bull/pulls/300/comments","review_comment_url":"https://api.github.com/repos/OptimalBits/bull/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OptimalBits/bull/issues/300/comments","statuses_url":"https://api.github.com/repos/OptimalBits/bull/statuses/9c70c24d3094958cea5f0ea20fde3fbe88a7790a","head":{"label":"mixmaxhq:fix/release-lock-on-process-stalled-jobs","ref":"fix/release-lock-on-process-stalled-jobs","sha":"9c70c24d3094958cea5f0ea20fde3fbe88a7790a","user":{"login":"mixmaxhq","id":7530142,"avatar_url":"https://avatars.githubusercontent.com/u/7530142?v=3","gravatar_id":"","url":"https://api.github.com/users/mixmaxhq","html_url":"https://github.com/mixmaxhq","followers_url":"https://api.github.com/users/mixmaxhq/followers","following_url":"https://api.github.com/users/mixmaxhq/following{/other_user}","gists_url":"https://api.github.com/users/mixmaxhq/gists{/gist_id}","starred_url":"https://api.github.com/users/mixmaxhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixmaxhq/subscriptions","organizations_url":"https://api.github.com/users/mixmaxhq/orgs","repos_url":"https://api.github.com/users/mixmaxhq/repos","events_url":"https://api.github.com/users/mixmaxhq/events{/privacy}","received_events_url":"https://api.github.com/users/mixmaxhq/received_events","type":"Organization","site_admin":false},"repo":{"id":52402151,"name":"bull","full_name":"mixmaxhq/bull","owner":{"login":"mixmaxhq","id":7530142,"avatar_url":"https://avatars.githubusercontent.com/u/7530142?v=3","gravatar_id":"","url":"https://api.github.com/users/mixmaxhq","html_url":"https://github.com/mixmaxhq","followers_url":"https://api.github.com/users/mixmaxhq/followers","following_url":"https://api.github.com/users/mixmaxhq/following{/other_user}","gists_url":"https://api.github.com/users/mixmaxhq/gists{/gist_id}","starred_url":"https://api.github.com/users/mixmaxhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixmaxhq/subscriptions","organizations_url":"https://api.github.com/users/mixmaxhq/orgs","repos_url":"https://api.github.com/users/mixmaxhq/repos","events_url":"https://api.github.com/users/mixmaxhq/events{/privacy}","received_events_url":"https://api.github.com/users/mixmaxhq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mixmaxhq/bull","description":"A NodeJS persistent job and message queue based on Redis","fork":true,"url":"https://api.github.com/repos/mixmaxhq/bull","forks_url":"https://api.github.com/repos/mixmaxhq/bull/forks","keys_url":"https://api.github.com/repos/mixmaxhq/bull/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mixmaxhq/bull/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mixmaxhq/bull/teams","hooks_url":"https://api.github.com/repos/mixmaxhq/bull/hooks","issue_events_url":"https://api.github.com/repos/mixmaxhq/bull/issues/events{/number}","events_url":"https://api.github.com/repos/mixmaxhq/bull/events","assignees_url":"https://api.github.com/repos/mixmaxhq/bull/assignees{/user}","branches_url":"https://api.github.com/repos/mixmaxhq/bull/branches{/branch}","tags_url":"https://api.github.com/repos/mixmaxhq/bull/tags","blobs_url":"https://api.github.com/repos/mixmaxhq/bull/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mixmaxhq/bull/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mixmaxhq/bull/git/refs{/sha}","trees_url":"https://api.github.com/repos/mixmaxhq/bull/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mixmaxhq/bull/statuses/{sha}","languages_url":"https://api.github.com/repos/mixmaxhq/bull/languages","stargazers_url":"https://api.github.com/repos/mixmaxhq/bull/stargazers","contributors_url":"https://api.github.com/repos/mixmaxhq/bull/contributors","subscribers_url":"https://api.github.com/repos/mixmaxhq/bull/subscribers","subscription_url":"https://api.github.com/repos/mixmaxhq/bull/subscription","commits_url":"https://api.github.com/repos/mixmaxhq/bull/commits{/sha}","git_commits_url":"https://api.github.com/repos/mixmaxhq/bull/git/commits{/sha}","comments_url":"https://api.github.com/repos/mixmaxhq/bull/comments{/number}","issue_comment_url":"https://api.github.com/repos/mixmaxhq/bull/issues/comments{/number}","contents_url":"https://api.github.com/repos/mixmaxhq/bull/contents/{+path}","compare_url":"https://api.github.com/repos/mixmaxhq/bull/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mixmaxhq/bull/merges","archive_url":"https://api.github.com/repos/mixmaxhq/bull/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mixmaxhq/bull/downloads","issues_url":"https://api.github.com/repos/mixmaxhq/bull/issues{/number}","pulls_url":"https://api.github.com/repos/mixmaxhq/bull/pulls{/number}","milestones_url":"https://api.github.com/repos/mixmaxhq/bull/milestones{/number}","notifications_url":"https://api.github.com/repos/mixmaxhq/bull/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mixmaxhq/bull/labels{/name}","releases_url":"https://api.github.com/repos/mixmaxhq/bull/releases{/id}","deployments_url":"https://api.github.com/repos/mixmaxhq/bull/deployments","created_at":"2016-02-24T00:35:03Z","updated_at":"2016-02-24T00:35:04Z","pushed_at":"2016-05-16T22:43:07Z","git_url":"git://github.com/mixmaxhq/bull.git","ssh_url":"git@github.com:mixmaxhq/bull.git","clone_url":"https://github.com/mixmaxhq/bull.git","svn_url":"https://github.com/mixmaxhq/bull","homepage":"","size":577,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"OptimalBits:master","ref":"master","sha":"23a672fb825539f9896f97c0499f857781660a84","user":{"login":"OptimalBits","id":945399,"avatar_url":"https://avatars.githubusercontent.com/u/945399?v=3","gravatar_id":"","url":"https://api.github.com/users/OptimalBits","html_url":"https://github.com/OptimalBits","followers_url":"https://api.github.com/users/OptimalBits/followers","following_url":"https://api.github.com/users/OptimalBits/following{/other_user}","gists_url":"https://api.github.com/users/OptimalBits/gists{/gist_id}","starred_url":"https://api.github.com/users/OptimalBits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OptimalBits/subscriptions","organizations_url":"https://api.github.com/users/OptimalBits/orgs","repos_url":"https://api.github.com/users/OptimalBits/repos","events_url":"https://api.github.com/users/OptimalBits/events{/privacy}","received_events_url":"https://api.github.com/users/OptimalBits/received_events","type":"Organization","site_admin":false},"repo":{"id":10999165,"name":"bull","full_name":"OptimalBits/bull","owner":{"login":"OptimalBits","id":945399,"avatar_url":"https://avatars.githubusercontent.com/u/945399?v=3","gravatar_id":"","url":"https://api.github.com/users/OptimalBits","html_url":"https://github.com/OptimalBits","followers_url":"https://api.github.com/users/OptimalBits/followers","following_url":"https://api.github.com/users/OptimalBits/following{/other_user}","gists_url":"https://api.github.com/users/OptimalBits/gists{/gist_id}","starred_url":"https://api.github.com/users/OptimalBits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OptimalBits/subscriptions","organizations_url":"https://api.github.com/users/OptimalBits/orgs","repos_url":"https://api.github.com/users/OptimalBits/repos","events_url":"https://api.github.com/users/OptimalBits/events{/privacy}","received_events_url":"https://api.github.com/users/OptimalBits/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OptimalBits/bull","description":"A NodeJS persistent job and message queue based on Redis","fork":false,"url":"https://api.github.com/repos/OptimalBits/bull","forks_url":"https://api.github.com/repos/OptimalBits/bull/forks","keys_url":"https://api.github.com/repos/OptimalBits/bull/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OptimalBits/bull/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OptimalBits/bull/teams","hooks_url":"https://api.github.com/repos/OptimalBits/bull/hooks","issue_events_url":"https://api.github.com/repos/OptimalBits/bull/issues/events{/number}","events_url":"https://api.github.com/repos/OptimalBits/bull/events","assignees_url":"https://api.github.com/repos/OptimalBits/bull/assignees{/user}","branches_url":"https://api.github.com/repos/OptimalBits/bull/branches{/branch}","tags_url":"https://api.github.com/repos/OptimalBits/bull/tags","blobs_url":"https://api.github.com/repos/OptimalBits/bull/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OptimalBits/bull/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OptimalBits/bull/git/refs{/sha}","trees_url":"https://api.github.com/repos/OptimalBits/bull/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OptimalBits/bull/statuses/{sha}","languages_url":"https://api.github.com/repos/OptimalBits/bull/languages","stargazers_url":"https://api.github.com/repos/OptimalBits/bull/stargazers","contributors_url":"https://api.github.com/repos/OptimalBits/bull/contributors","subscribers_url":"https://api.github.com/repos/OptimalBits/bull/subscribers","subscription_url":"https://api.github.com/repos/OptimalBits/bull/subscription","commits_url":"https://api.github.com/repos/OptimalBits/bull/commits{/sha}","git_commits_url":"https://api.github.com/repos/OptimalBits/bull/git/commits{/sha}","comments_url":"https://api.github.com/repos/OptimalBits/bull/comments{/number}","issue_comment_url":"https://api.github.com/repos/OptimalBits/bull/issues/comments{/number}","contents_url":"https://api.github.com/repos/OptimalBits/bull/contents/{+path}","compare_url":"https://api.github.com/repos/OptimalBits/bull/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OptimalBits/bull/merges","archive_url":"https://api.github.com/repos/OptimalBits/bull/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OptimalBits/bull/downloads","issues_url":"https://api.github.com/repos/OptimalBits/bull/issues{/number}","pulls_url":"https://api.github.com/repos/OptimalBits/bull/pulls{/number}","milestones_url":"https://api.github.com/repos/OptimalBits/bull/milestones{/number}","notifications_url":"https://api.github.com/repos/OptimalBits/bull/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OptimalBits/bull/labels{/name}","releases_url":"https://api.github.com/repos/OptimalBits/bull/releases{/id}","deployments_url":"https://api.github.com/repos/OptimalBits/bull/deployments","created_at":"2013-06-27T14:35:35Z","updated_at":"2016-05-16T16:58:55Z","pushed_at":"2016-05-16T22:45:56Z","git_url":"git://github.com/OptimalBits/bull.git","ssh_url":"git@github.com:OptimalBits/bull.git","clone_url":"https://github.com/OptimalBits/bull.git","svn_url":"https://github.com/OptimalBits/bull","homepage":"","size":664,"stargazers_count":926,"watchers_count":926,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":79,"forks":103,"open_issues":79,"watchers":926,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/300"},"html":{"href":"https://github.com/OptimalBits/bull/pull/300"},"issue":{"href":"https://api.github.com/repos/OptimalBits/bull/issues/300"},"comments":{"href":"https://api.github.com/repos/OptimalBits/bull/issues/300/comments"},"review_comments":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/300/comments"},"review_comment":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OptimalBits/bull/pulls/300/commits"},"statuses":{"href":"https://api.github.com/repos/OptimalBits/bull/statuses/9c70c24d3094958cea5f0ea20fde3fbe88a7790a"}}}}