{"action":"created","comment":{"url":"https://api.github.com/repos/segmentio/consul-go/pulls/comments/151741499","pull_request_review_id":77503869,"id":151741499,"diff_hunk":"@@ -182,29 +182,32 @@ func (s *sessionCtx) id() string {\n \treturn string(s.session.ID)\n }\n \n-func (s *sessionCtx) run() {\n+func (s *sessionCtx) run(deadline time.Time) {\n \ttimeout := s.session.TTL / 3\n \tticker := time.NewTicker(timeout)\n \tdefer ticker.Stop()\n \n \tfor {\n \t\tselect {\n-\t\tcase <-ticker.C:\n \t\tcase <-s.done:\n \t\t\treturn\n \t\tcase <-s.ctx.Done():\n \t\t\ts.cancelWithError(s.ctx.Err())\n \t\t\treturn\n-\t\t}\n-\n-\t\t// TODO: tolerate failures here? add retries with backoff?\n-\t\trenewSessionCtx, renewSessionCancel := context.WithTimeout(s, timeout)\n-\t\terr := s.session.Client.renewSession(renewSessionCtx, s.id())\n-\t\trenewSessionCancel()\n-\n-\t\tif err != nil {\n-\t\t\ts.cancelWithError(err)\n-\t\t\treturn\n+\t\tcase now := <-ticker.C:\n+\t\t\trenewSessionCtx, renewSessionCancel := context.WithTimeout(s, timeout)\n+\t\t\terr := s.session.Client.renewSession(renewSessionCtx, s.id())\n+\t\t\trenewSessionCancel()\n+\n+\t\t\tif err != nil {\n+\t\t\t\tif now.Before(deadline) {\n+\t\t\t\t\tcontinue","path":"session.go","position":44,"original_position":44,"commit_id":"afe5e4a1c26970d5eff6f19ba379a4735bed117b","original_commit_id":"afe5e4a1c26970d5eff6f19ba379a4735bed117b","user":{"login":"abraithwaite","id":3791413,"avatar_url":"https://avatars0.githubusercontent.com/u/3791413?v=4","gravatar_id":"","url":"https://api.github.com/users/abraithwaite","html_url":"https://github.com/abraithwaite","followers_url":"https://api.github.com/users/abraithwaite/followers","following_url":"https://api.github.com/users/abraithwaite/following{/other_user}","gists_url":"https://api.github.com/users/abraithwaite/gists{/gist_id}","starred_url":"https://api.github.com/users/abraithwaite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abraithwaite/subscriptions","organizations_url":"https://api.github.com/users/abraithwaite/orgs","repos_url":"https://api.github.com/users/abraithwaite/repos","events_url":"https://api.github.com/users/abraithwaite/events{/privacy}","received_events_url":"https://api.github.com/users/abraithwaite/received_events","type":"User","site_admin":false},"body":"Should we log it anyway?  Could see this potentially causing issues if we get caught in a fail loop.","created_at":"2017-11-17T17:20:46Z","updated_at":"2017-11-17T17:20:47Z","html_url":"https://github.com/segmentio/consul-go/pull/40#discussion_r151741499","pull_request_url":"https://api.github.com/repos/segmentio/consul-go/pulls/40","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/comments/151741499"},"html":{"href":"https://github.com/segmentio/consul-go/pull/40#discussion_r151741499"},"pull_request":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/segmentio/consul-go/pulls/40","id":153216792,"html_url":"https://github.com/segmentio/consul-go/pull/40","diff_url":"https://github.com/segmentio/consul-go/pull/40.diff","patch_url":"https://github.com/segmentio/consul-go/pull/40.patch","issue_url":"https://api.github.com/repos/segmentio/consul-go/issues/40","number":40,"state":"open","locked":false,"title":"resilient sessions","user":{"login":"achille-roussel","id":865510,"avatar_url":"https://avatars3.githubusercontent.com/u/865510?v=4","gravatar_id":"","url":"https://api.github.com/users/achille-roussel","html_url":"https://github.com/achille-roussel","followers_url":"https://api.github.com/users/achille-roussel/followers","following_url":"https://api.github.com/users/achille-roussel/following{/other_user}","gists_url":"https://api.github.com/users/achille-roussel/gists{/gist_id}","starred_url":"https://api.github.com/users/achille-roussel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achille-roussel/subscriptions","organizations_url":"https://api.github.com/users/achille-roussel/orgs","repos_url":"https://api.github.com/users/achille-roussel/repos","events_url":"https://api.github.com/users/achille-roussel/events{/privacy}","received_events_url":"https://api.github.com/users/achille-roussel/received_events","type":"User","site_admin":false},"body":"We're seeing our consul agents disconnect from time to time, and causing programs to lose their locks. However, the session that the lock is attached to may still be valid as long as it hasn't reached its TTL.\r\n\r\nThis PR changes the session management code to be more resilient to temporary failures, ignoring them as long as the session's TTL hasn't been reached.","created_at":"2017-11-17T05:13:32Z","updated_at":"2017-11-17T17:20:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79a8edaa0c7b0d74602d4cd6132a97ff178f8111","assignee":null,"assignees":[],"requested_reviewers":[{"login":"f2prateek","id":843979,"avatar_url":"https://avatars2.githubusercontent.com/u/843979?v=4","gravatar_id":"","url":"https://api.github.com/users/f2prateek","html_url":"https://github.com/f2prateek","followers_url":"https://api.github.com/users/f2prateek/followers","following_url":"https://api.github.com/users/f2prateek/following{/other_user}","gists_url":"https://api.github.com/users/f2prateek/gists{/gist_id}","starred_url":"https://api.github.com/users/f2prateek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/f2prateek/subscriptions","organizations_url":"https://api.github.com/users/f2prateek/orgs","repos_url":"https://api.github.com/users/f2prateek/repos","events_url":"https://api.github.com/users/f2prateek/events{/privacy}","received_events_url":"https://api.github.com/users/f2prateek/received_events","type":"User","site_admin":false},{"login":"yields","id":1661587,"avatar_url":"https://avatars2.githubusercontent.com/u/1661587?v=4","gravatar_id":"","url":"https://api.github.com/users/yields","html_url":"https://github.com/yields","followers_url":"https://api.github.com/users/yields/followers","following_url":"https://api.github.com/users/yields/following{/other_user}","gists_url":"https://api.github.com/users/yields/gists{/gist_id}","starred_url":"https://api.github.com/users/yields/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yields/subscriptions","organizations_url":"https://api.github.com/users/yields/orgs","repos_url":"https://api.github.com/users/yields/repos","events_url":"https://api.github.com/users/yields/events{/privacy}","received_events_url":"https://api.github.com/users/yields/received_events","type":"User","site_admin":false},{"login":"tsholmes","id":2865426,"avatar_url":"https://avatars0.githubusercontent.com/u/2865426?v=4","gravatar_id":"","url":"https://api.github.com/users/tsholmes","html_url":"https://github.com/tsholmes","followers_url":"https://api.github.com/users/tsholmes/followers","following_url":"https://api.github.com/users/tsholmes/following{/other_user}","gists_url":"https://api.github.com/users/tsholmes/gists{/gist_id}","starred_url":"https://api.github.com/users/tsholmes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsholmes/subscriptions","organizations_url":"https://api.github.com/users/tsholmes/orgs","repos_url":"https://api.github.com/users/tsholmes/repos","events_url":"https://api.github.com/users/tsholmes/events{/privacy}","received_events_url":"https://api.github.com/users/tsholmes/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/segmentio/consul-go/pulls/40/commits","review_comments_url":"https://api.github.com/repos/segmentio/consul-go/pulls/40/comments","review_comment_url":"https://api.github.com/repos/segmentio/consul-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/segmentio/consul-go/issues/40/comments","statuses_url":"https://api.github.com/repos/segmentio/consul-go/statuses/afe5e4a1c26970d5eff6f19ba379a4735bed117b","head":{"label":"segmentio:resilient-sessions","ref":"resilient-sessions","sha":"afe5e4a1c26970d5eff6f19ba379a4735bed117b","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":90301546,"name":"consul-go","full_name":"segmentio/consul-go","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/consul-go","description":"Go package providing building blocks for interacting with Consul.","fork":false,"url":"https://api.github.com/repos/segmentio/consul-go","forks_url":"https://api.github.com/repos/segmentio/consul-go/forks","keys_url":"https://api.github.com/repos/segmentio/consul-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/consul-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/consul-go/teams","hooks_url":"https://api.github.com/repos/segmentio/consul-go/hooks","issue_events_url":"https://api.github.com/repos/segmentio/consul-go/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/consul-go/events","assignees_url":"https://api.github.com/repos/segmentio/consul-go/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/consul-go/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/consul-go/tags","blobs_url":"https://api.github.com/repos/segmentio/consul-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/consul-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/consul-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/consul-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/consul-go/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/consul-go/languages","stargazers_url":"https://api.github.com/repos/segmentio/consul-go/stargazers","contributors_url":"https://api.github.com/repos/segmentio/consul-go/contributors","subscribers_url":"https://api.github.com/repos/segmentio/consul-go/subscribers","subscription_url":"https://api.github.com/repos/segmentio/consul-go/subscription","commits_url":"https://api.github.com/repos/segmentio/consul-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/consul-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/consul-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/consul-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/consul-go/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/consul-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/consul-go/merges","archive_url":"https://api.github.com/repos/segmentio/consul-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/consul-go/downloads","issues_url":"https://api.github.com/repos/segmentio/consul-go/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/consul-go/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/consul-go/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/consul-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/consul-go/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/consul-go/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/consul-go/deployments","created_at":"2017-05-04T19:21:57Z","updated_at":"2017-11-14T19:18:58Z","pushed_at":"2017-11-17T05:13:32Z","git_url":"git://github.com/segmentio/consul-go.git","ssh_url":"git@github.com:segmentio/consul-go.git","clone_url":"https://github.com/segmentio/consul-go.git","svn_url":"https://github.com/segmentio/consul-go","homepage":null,"size":121,"stargazers_count":18,"watchers_count":18,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":18,"default_branch":"master"}},"base":{"label":"segmentio:master","ref":"master","sha":"2592addf7a249bae26769fa9085122fdfb5d5c4c","user":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"repo":{"id":90301546,"name":"consul-go","full_name":"segmentio/consul-go","owner":{"login":"segmentio","id":819518,"avatar_url":"https://avatars0.githubusercontent.com/u/819518?v=4","gravatar_id":"","url":"https://api.github.com/users/segmentio","html_url":"https://github.com/segmentio","followers_url":"https://api.github.com/users/segmentio/followers","following_url":"https://api.github.com/users/segmentio/following{/other_user}","gists_url":"https://api.github.com/users/segmentio/gists{/gist_id}","starred_url":"https://api.github.com/users/segmentio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segmentio/subscriptions","organizations_url":"https://api.github.com/users/segmentio/orgs","repos_url":"https://api.github.com/users/segmentio/repos","events_url":"https://api.github.com/users/segmentio/events{/privacy}","received_events_url":"https://api.github.com/users/segmentio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/segmentio/consul-go","description":"Go package providing building blocks for interacting with Consul.","fork":false,"url":"https://api.github.com/repos/segmentio/consul-go","forks_url":"https://api.github.com/repos/segmentio/consul-go/forks","keys_url":"https://api.github.com/repos/segmentio/consul-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/segmentio/consul-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/segmentio/consul-go/teams","hooks_url":"https://api.github.com/repos/segmentio/consul-go/hooks","issue_events_url":"https://api.github.com/repos/segmentio/consul-go/issues/events{/number}","events_url":"https://api.github.com/repos/segmentio/consul-go/events","assignees_url":"https://api.github.com/repos/segmentio/consul-go/assignees{/user}","branches_url":"https://api.github.com/repos/segmentio/consul-go/branches{/branch}","tags_url":"https://api.github.com/repos/segmentio/consul-go/tags","blobs_url":"https://api.github.com/repos/segmentio/consul-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/segmentio/consul-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/segmentio/consul-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/segmentio/consul-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/segmentio/consul-go/statuses/{sha}","languages_url":"https://api.github.com/repos/segmentio/consul-go/languages","stargazers_url":"https://api.github.com/repos/segmentio/consul-go/stargazers","contributors_url":"https://api.github.com/repos/segmentio/consul-go/contributors","subscribers_url":"https://api.github.com/repos/segmentio/consul-go/subscribers","subscription_url":"https://api.github.com/repos/segmentio/consul-go/subscription","commits_url":"https://api.github.com/repos/segmentio/consul-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/segmentio/consul-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/segmentio/consul-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/segmentio/consul-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/segmentio/consul-go/contents/{+path}","compare_url":"https://api.github.com/repos/segmentio/consul-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/segmentio/consul-go/merges","archive_url":"https://api.github.com/repos/segmentio/consul-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/segmentio/consul-go/downloads","issues_url":"https://api.github.com/repos/segmentio/consul-go/issues{/number}","pulls_url":"https://api.github.com/repos/segmentio/consul-go/pulls{/number}","milestones_url":"https://api.github.com/repos/segmentio/consul-go/milestones{/number}","notifications_url":"https://api.github.com/repos/segmentio/consul-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/segmentio/consul-go/labels{/name}","releases_url":"https://api.github.com/repos/segmentio/consul-go/releases{/id}","deployments_url":"https://api.github.com/repos/segmentio/consul-go/deployments","created_at":"2017-05-04T19:21:57Z","updated_at":"2017-11-14T19:18:58Z","pushed_at":"2017-11-17T05:13:32Z","git_url":"git://github.com/segmentio/consul-go.git","ssh_url":"git@github.com:segmentio/consul-go.git","clone_url":"https://github.com/segmentio/consul-go.git","svn_url":"https://github.com/segmentio/consul-go","homepage":null,"size":121,"stargazers_count":18,"watchers_count":18,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/40"},"html":{"href":"https://github.com/segmentio/consul-go/pull/40"},"issue":{"href":"https://api.github.com/repos/segmentio/consul-go/issues/40"},"comments":{"href":"https://api.github.com/repos/segmentio/consul-go/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/segmentio/consul-go/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/segmentio/consul-go/statuses/afe5e4a1c26970d5eff6f19ba379a4735bed117b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"abraithwaite"}}