{"action":"created","comment":{"url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/comments/65977600","id":65977600,"diff_hunk":"@@ -266,57 +260,24 @@ remove_job_int(#job{} = Job) ->\n     ets:delete(?MODULE, Job#job.id).\n \n \n--spec job_count() -> non_neg_integer().\n-job_count() ->\n-    ets:info(?MODULE, size).\n-\n-\n -spec running_job_count() -> non_neg_integer().\n running_job_count() ->\n-    MatchSpec = [{#job{pid = '$1', _='_'},\n-        [{is_pid,'$1'}],\n-        [true]}\n-    ],\n-    ets:select_count(?MODULE, MatchSpec).\n-\n+    ets:info(?MODULE, size) - pending_job_count().\n \n -spec running_jobs() -> [#job{}].\n running_jobs() ->\n-    MatchSpec = [{#job{pid = '$1', _='_'},\n-        [{is_pid,'$1'}],\n-        ['$_']}\n-    ],\n-    ets:select(?MODULE, MatchSpec).\n+    ets:tab2list(?MODULE) -- pending_jobs().\n \n \n -spec pending_job_count() -> non_neg_integer().\n pending_job_count() ->\n-    Now = unix_now(),\n-    % Select jobs where the pid is undefined and the exponential backoff\n-    % threshold has been crossed.\n-    MatchSpec = [{#job{pid = '$1',errored_at = '$2',errors = '$3', _='_'},\n-        [{'not',{is_pid,'$1'}},\n-        {'<',{'-',{'*',{'bsl',1,'$3'},?ERROR_BACKOFF_MILLIS},\n-        {'*',{'-',{const,Now},'$2'},1000}},\n-        0}],\n-        [true]}\n-    ],\n+    MatchSpec = [{#job{pid='$1', _='_'}, [{'not', {'is_pid', '$1'}}], [true]}],","path":"src/couch_replicator_scheduler.erl","position":null,"original_position":153,"commit_id":"913357138f451c300c92ab00a82deda168462228","original_commit_id":"15d295bf79e595fecca05de156a6a3b7ab946b54","user":{"login":"sagelywizard","id":167249,"avatar_url":"https://avatars.githubusercontent.com/u/167249?v=3","gravatar_id":"","url":"https://api.github.com/users/sagelywizard","html_url":"https://github.com/sagelywizard","followers_url":"https://api.github.com/users/sagelywizard/followers","following_url":"https://api.github.com/users/sagelywizard/following{/other_user}","gists_url":"https://api.github.com/users/sagelywizard/gists{/gist_id}","starred_url":"https://api.github.com/users/sagelywizard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagelywizard/subscriptions","organizations_url":"https://api.github.com/users/sagelywizard/orgs","repos_url":"https://api.github.com/users/sagelywizard/repos","events_url":"https://api.github.com/users/sagelywizard/events{/privacy}","received_events_url":"https://api.github.com/users/sagelywizard/received_events","type":"User","site_admin":false},"body":"Changed","created_at":"2016-06-06T22:00:48Z","updated_at":"2016-06-06T22:00:49Z","html_url":"https://github.com/cloudant/couchdb-couch-replicator/pull/19#discussion_r65977600","pull_request_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/comments/65977600"},"html":{"href":"https://github.com/cloudant/couchdb-couch-replicator/pull/19#discussion_r65977600"},"pull_request":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19","id":72583431,"html_url":"https://github.com/cloudant/couchdb-couch-replicator/pull/19","diff_url":"https://github.com/cloudant/couchdb-couch-replicator/pull/19.diff","patch_url":"https://github.com/cloudant/couchdb-couch-replicator/pull/19.patch","issue_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/19","number":19,"state":"open","locked":false,"title":"Add exponential backoff for erroring jobs","user":{"login":"sagelywizard","id":167249,"avatar_url":"https://avatars.githubusercontent.com/u/167249?v=3","gravatar_id":"","url":"https://api.github.com/users/sagelywizard","html_url":"https://github.com/sagelywizard","followers_url":"https://api.github.com/users/sagelywizard/followers","following_url":"https://api.github.com/users/sagelywizard/following{/other_user}","gists_url":"https://api.github.com/users/sagelywizard/gists{/gist_id}","starred_url":"https://api.github.com/users/sagelywizard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagelywizard/subscriptions","organizations_url":"https://api.github.com/users/sagelywizard/orgs","repos_url":"https://api.github.com/users/sagelywizard/repos","events_url":"https://api.github.com/users/sagelywizard/events{/privacy}","received_events_url":"https://api.github.com/users/sagelywizard/received_events","type":"User","site_admin":false},"body":"This PR adds exponential backoff for erroring jobs. It does this by adding two fields to the job record.\r\n\r\n* The number of times a job has errored in a row\r\n* The last time a job errored\r\n\r\nFor every time it gets scheduled and errors, it gets suspended proportionally to `2^Errors`. Once the job completes a time window successfully, its running error count is reset to 0.","created_at":"2016-06-03T23:30:16Z","updated_at":"2016-06-06T22:00:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6bbb2c2e6f0ab1900f2dacb94753936e4ee97bd9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19/commits","review_comments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19/comments","review_comment_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/19/comments","statuses_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/statuses/913357138f451c300c92ab00a82deda168462228","head":{"label":"cloudant:63012-scheduler-ben","ref":"63012-scheduler-ben","sha":"913357138f451c300c92ab00a82deda168462228","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":38246096,"name":"couchdb-couch-replicator","full_name":"cloudant/couchdb-couch-replicator","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/couchdb-couch-replicator","description":"Mirror of Apache CouchDB","fork":true,"url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator","forks_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/forks","keys_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/teams","hooks_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/hooks","issue_events_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/events","assignees_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/tags","blobs_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/languages","stargazers_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/stargazers","contributors_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/contributors","subscribers_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/subscribers","subscription_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/subscription","commits_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/merges","archive_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/downloads","issues_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/deployments","created_at":"2015-06-29T12:19:20Z","updated_at":"2016-05-13T14:06:45Z","pushed_at":"2016-06-06T22:00:44Z","git_url":"git://github.com/cloudant/couchdb-couch-replicator.git","ssh_url":"git@github.com:cloudant/couchdb-couch-replicator.git","clone_url":"https://github.com/cloudant/couchdb-couch-replicator.git","svn_url":"https://github.com/cloudant/couchdb-couch-replicator","homepage":null,"size":4859,"stargazers_count":0,"watchers_count":0,"language":"Erlang","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"cloudant:63012-scheduler","ref":"63012-scheduler","sha":"ed40d85e7752af6a433745d5141a41b892e7a1e4","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":38246096,"name":"couchdb-couch-replicator","full_name":"cloudant/couchdb-couch-replicator","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/couchdb-couch-replicator","description":"Mirror of Apache CouchDB","fork":true,"url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator","forks_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/forks","keys_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/teams","hooks_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/hooks","issue_events_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/events","assignees_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/tags","blobs_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/languages","stargazers_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/stargazers","contributors_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/contributors","subscribers_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/subscribers","subscription_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/subscription","commits_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/merges","archive_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/downloads","issues_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/deployments","created_at":"2015-06-29T12:19:20Z","updated_at":"2016-05-13T14:06:45Z","pushed_at":"2016-06-06T22:00:44Z","git_url":"git://github.com/cloudant/couchdb-couch-replicator.git","ssh_url":"git@github.com:cloudant/couchdb-couch-replicator.git","clone_url":"https://github.com/cloudant/couchdb-couch-replicator.git","svn_url":"https://github.com/cloudant/couchdb-couch-replicator","homepage":null,"size":4859,"stargazers_count":0,"watchers_count":0,"language":"Erlang","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19"},"html":{"href":"https://github.com/cloudant/couchdb-couch-replicator/pull/19"},"issue":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/19"},"comments":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/cloudant/couchdb-couch-replicator/statuses/913357138f451c300c92ab00a82deda168462228"}}}}
{"actor":{"display_login":"sagelywizard"}}