{"action":"created","comment":{"url":"https://api.github.com/repos/square/p2/pulls/comments/78590693","id":78590693,"diff_hunk":"@@ -34,8 +40,29 @@ func SessionManager(\n \tdone chan struct{},\n \tlogger logging.Logger,\n ) {\n+\tprng := randseed.NewRand()\n+\tminDelay := time.Duration(*SessionRetrySeconds) * time.Second\n+\tmaxDelay := time.Duration(*SessionMaxRetrySeconds) * time.Second\n+\tuseDelay := false\n+\tvar delay time.Duration\n+\n \tlogger.NoFields().Info(\"session manager: starting up\")\n \tfor {\n+\t\tif useDelay {\n+\t\t\t// Normalize timeout range\n+\t\t\tif delay < minDelay {\n+\t\t\t\tdelay = minDelay\n+\t\t\t} else if delay > maxDelay {\n+\t\t\t\tdelay = maxDelay\n+\t\t\t}\n+\t\t\tselect {\n+\t\t\tcase <-time.After(time.Duration(prng.Int63n(int64(delay)))):","path":"pkg/kp/consulutil/session_controller.go","position":41,"original_position":41,"commit_id":"ab8781e6d7466f270a81febeab5c0e9f394a38e3","original_commit_id":"ab8781e6d7466f270a81febeab5c0e9f394a38e3","user":{"login":"anthonybishopric","id":540783,"avatar_url":"https://avatars.githubusercontent.com/u/540783?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonybishopric","html_url":"https://github.com/anthonybishopric","followers_url":"https://api.github.com/users/anthonybishopric/followers","following_url":"https://api.github.com/users/anthonybishopric/following{/other_user}","gists_url":"https://api.github.com/users/anthonybishopric/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonybishopric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonybishopric/subscriptions","organizations_url":"https://api.github.com/users/anthonybishopric/orgs","repos_url":"https://api.github.com/users/anthonybishopric/repos","events_url":"https://api.github.com/users/anthonybishopric/events{/privacy}","received_events_url":"https://api.github.com/users/anthonybishopric/received_events","type":"User","site_admin":false},"body":"Should this be `time.Duration(minDelay + prng.Int63n(int64(delay-minDelay)))`? Really, I'm poking at the meaning of \"minDelay\" when it could actually wait less time than this value implies.","created_at":"2016-09-13T16:04:38Z","updated_at":"2016-09-13T16:04:38Z","html_url":"https://github.com/square/p2/pull/645#discussion_r78590693","pull_request_url":"https://api.github.com/repos/square/p2/pulls/645","_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/comments/78590693"},"html":{"href":"https://github.com/square/p2/pull/645#discussion_r78590693"},"pull_request":{"href":"https://api.github.com/repos/square/p2/pulls/645"}}},"pull_request":{"url":"https://api.github.com/repos/square/p2/pulls/645","id":84951681,"html_url":"https://github.com/square/p2/pull/645","diff_url":"https://github.com/square/p2/pull/645.diff","patch_url":"https://github.com/square/p2/pull/645.patch","issue_url":"https://api.github.com/repos/square/p2/issues/645","number":645,"state":"open","locked":false,"title":"consulutil: Add exponential backoff to SessionManager","user":{"login":"bwester","id":1501338,"avatar_url":"https://avatars.githubusercontent.com/u/1501338?v=3","gravatar_id":"","url":"https://api.github.com/users/bwester","html_url":"https://github.com/bwester","followers_url":"https://api.github.com/users/bwester/followers","following_url":"https://api.github.com/users/bwester/following{/other_user}","gists_url":"https://api.github.com/users/bwester/gists{/gist_id}","starred_url":"https://api.github.com/users/bwester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwester/subscriptions","organizations_url":"https://api.github.com/users/bwester/orgs","repos_url":"https://api.github.com/users/bwester/repos","events_url":"https://api.github.com/users/bwester/events{/privacy}","received_events_url":"https://api.github.com/users/bwester/received_events","type":"User","site_admin":false},"body":"Add an exponential backoff strategy to SessionManager to deal with\r\nerrors encountered while creating a session. Session loss is a\r\nhighly-correlated event, so jitter is added to mitigate a thundering\r\nherd (mostly preparers) attempting to reestablish their sessions after a\r\nloss occurrs.\r\n\r\nErrors encountered while renewing a session are probably a symptom of an\r\noverloaded Consul server, but it isn't clear how to use an exponential\r\nbackoff to mitigate that problem. This changes uses a heuristic of\r\nsending the next create request after the maximum timeout from the last\r\nsuccessful create.","created_at":"2016-09-12T21:52:44Z","updated_at":"2016-09-13T16:04:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abb73a911a4d67dcdb182be40208f17225916f90","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/square/p2/pulls/645/commits","review_comments_url":"https://api.github.com/repos/square/p2/pulls/645/comments","review_comment_url":"https://api.github.com/repos/square/p2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/p2/issues/645/comments","statuses_url":"https://api.github.com/repos/square/p2/statuses/ab8781e6d7466f270a81febeab5c0e9f394a38e3","head":{"label":"bwester:session-backoff","ref":"session-backoff","sha":"ab8781e6d7466f270a81febeab5c0e9f394a38e3","user":{"login":"bwester","id":1501338,"avatar_url":"https://avatars.githubusercontent.com/u/1501338?v=3","gravatar_id":"","url":"https://api.github.com/users/bwester","html_url":"https://github.com/bwester","followers_url":"https://api.github.com/users/bwester/followers","following_url":"https://api.github.com/users/bwester/following{/other_user}","gists_url":"https://api.github.com/users/bwester/gists{/gist_id}","starred_url":"https://api.github.com/users/bwester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwester/subscriptions","organizations_url":"https://api.github.com/users/bwester/orgs","repos_url":"https://api.github.com/users/bwester/repos","events_url":"https://api.github.com/users/bwester/events{/privacy}","received_events_url":"https://api.github.com/users/bwester/received_events","type":"User","site_admin":false},"repo":{"id":33944046,"name":"p2","full_name":"bwester/p2","owner":{"login":"bwester","id":1501338,"avatar_url":"https://avatars.githubusercontent.com/u/1501338?v=3","gravatar_id":"","url":"https://api.github.com/users/bwester","html_url":"https://github.com/bwester","followers_url":"https://api.github.com/users/bwester/followers","following_url":"https://api.github.com/users/bwester/following{/other_user}","gists_url":"https://api.github.com/users/bwester/gists{/gist_id}","starred_url":"https://api.github.com/users/bwester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwester/subscriptions","organizations_url":"https://api.github.com/users/bwester/orgs","repos_url":"https://api.github.com/users/bwester/repos","events_url":"https://api.github.com/users/bwester/events{/privacy}","received_events_url":"https://api.github.com/users/bwester/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bwester/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":true,"url":"https://api.github.com/repos/bwester/p2","forks_url":"https://api.github.com/repos/bwester/p2/forks","keys_url":"https://api.github.com/repos/bwester/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bwester/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bwester/p2/teams","hooks_url":"https://api.github.com/repos/bwester/p2/hooks","issue_events_url":"https://api.github.com/repos/bwester/p2/issues/events{/number}","events_url":"https://api.github.com/repos/bwester/p2/events","assignees_url":"https://api.github.com/repos/bwester/p2/assignees{/user}","branches_url":"https://api.github.com/repos/bwester/p2/branches{/branch}","tags_url":"https://api.github.com/repos/bwester/p2/tags","blobs_url":"https://api.github.com/repos/bwester/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bwester/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bwester/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/bwester/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bwester/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/bwester/p2/languages","stargazers_url":"https://api.github.com/repos/bwester/p2/stargazers","contributors_url":"https://api.github.com/repos/bwester/p2/contributors","subscribers_url":"https://api.github.com/repos/bwester/p2/subscribers","subscription_url":"https://api.github.com/repos/bwester/p2/subscription","commits_url":"https://api.github.com/repos/bwester/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/bwester/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/bwester/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/bwester/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/bwester/p2/contents/{+path}","compare_url":"https://api.github.com/repos/bwester/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bwester/p2/merges","archive_url":"https://api.github.com/repos/bwester/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bwester/p2/downloads","issues_url":"https://api.github.com/repos/bwester/p2/issues{/number}","pulls_url":"https://api.github.com/repos/bwester/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/bwester/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/bwester/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bwester/p2/labels{/name}","releases_url":"https://api.github.com/repos/bwester/p2/releases{/id}","deployments_url":"https://api.github.com/repos/bwester/p2/deployments","created_at":"2015-04-14T16:40:53Z","updated_at":"2016-01-11T23:55:50Z","pushed_at":"2016-09-12T21:51:47Z","git_url":"git://github.com/bwester/p2.git","ssh_url":"git@github.com:bwester/p2.git","clone_url":"https://github.com/bwester/p2.git","svn_url":"https://github.com/bwester/p2","homepage":"","size":41052,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"square:master","ref":"master","sha":"e112c62a0b4e44c9fa030154ac5f8354d26b10ff","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":25320424,"name":"p2","full_name":"square/p2","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/p2","description":"Platypus Platform: Tools for Scalable Deployment","fork":false,"url":"https://api.github.com/repos/square/p2","forks_url":"https://api.github.com/repos/square/p2/forks","keys_url":"https://api.github.com/repos/square/p2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/p2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/p2/teams","hooks_url":"https://api.github.com/repos/square/p2/hooks","issue_events_url":"https://api.github.com/repos/square/p2/issues/events{/number}","events_url":"https://api.github.com/repos/square/p2/events","assignees_url":"https://api.github.com/repos/square/p2/assignees{/user}","branches_url":"https://api.github.com/repos/square/p2/branches{/branch}","tags_url":"https://api.github.com/repos/square/p2/tags","blobs_url":"https://api.github.com/repos/square/p2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/p2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/p2/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/p2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/p2/statuses/{sha}","languages_url":"https://api.github.com/repos/square/p2/languages","stargazers_url":"https://api.github.com/repos/square/p2/stargazers","contributors_url":"https://api.github.com/repos/square/p2/contributors","subscribers_url":"https://api.github.com/repos/square/p2/subscribers","subscription_url":"https://api.github.com/repos/square/p2/subscription","commits_url":"https://api.github.com/repos/square/p2/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/p2/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/p2/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/p2/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/p2/contents/{+path}","compare_url":"https://api.github.com/repos/square/p2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/p2/merges","archive_url":"https://api.github.com/repos/square/p2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/p2/downloads","issues_url":"https://api.github.com/repos/square/p2/issues{/number}","pulls_url":"https://api.github.com/repos/square/p2/pulls{/number}","milestones_url":"https://api.github.com/repos/square/p2/milestones{/number}","notifications_url":"https://api.github.com/repos/square/p2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/p2/labels{/name}","releases_url":"https://api.github.com/repos/square/p2/releases{/id}","deployments_url":"https://api.github.com/repos/square/p2/deployments","created_at":"2014-10-16T20:31:12Z","updated_at":"2016-09-09T21:19:34Z","pushed_at":"2016-09-13T00:03:35Z","git_url":"git://github.com/square/p2.git","ssh_url":"git@github.com:square/p2.git","clone_url":"https://github.com/square/p2.git","svn_url":"https://github.com/square/p2","homepage":"","size":41484,"stargazers_count":123,"watchers_count":123,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"open_issues_count":10,"forks":22,"open_issues":10,"watchers":123,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/p2/pulls/645"},"html":{"href":"https://github.com/square/p2/pull/645"},"issue":{"href":"https://api.github.com/repos/square/p2/issues/645"},"comments":{"href":"https://api.github.com/repos/square/p2/issues/645/comments"},"review_comments":{"href":"https://api.github.com/repos/square/p2/pulls/645/comments"},"review_comment":{"href":"https://api.github.com/repos/square/p2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/p2/pulls/645/commits"},"statuses":{"href":"https://api.github.com/repos/square/p2/statuses/ab8781e6d7466f270a81febeab5c0e9f394a38e3"}}}}
{"actor":{"display_login":"anthonybishopric"}}