{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/242776857","pull_request_review_id":186369318,"id":242776857,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0Mjc3Njg1Nw==","diff_hunk":"@@ -387,21 +388,50 @@ func (s *Server) KillAllConnections() {\n \t}\n }\n \n+var gracefulCloseConnectionsTimeout = 15 * time.Second\n+\n+// TryGracefulDown will try graceful close all connection first with timeout. if timeout, will close all connection directly.\n+func (s *Server) TryGracefulDown() {\n+\tctx, cancel := context.WithCancel(context.Background())\n+\ttimeout := time.Tick(gracefulCloseConnectionsTimeout)","path":"server/server.go","position":17,"original_position":17,"commit_id":"11105d1283571528fb319d3c7c5dbb084de2fce9","original_commit_id":"11105d1283571528fb319d3c7c5dbb084de2fce9","user":{"login":"tiancaiamao","id":1420062,"node_id":"MDQ6VXNlcjE0MjAwNjI=","avatar_url":"https://avatars2.githubusercontent.com/u/1420062?v=4","gravatar_id":"","url":"https://api.github.com/users/tiancaiamao","html_url":"https://github.com/tiancaiamao","followers_url":"https://api.github.com/users/tiancaiamao/followers","following_url":"https://api.github.com/users/tiancaiamao/following{/other_user}","gists_url":"https://api.github.com/users/tiancaiamao/gists{/gist_id}","starred_url":"https://api.github.com/users/tiancaiamao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiancaiamao/subscriptions","organizations_url":"https://api.github.com/users/tiancaiamao/orgs","repos_url":"https://api.github.com/users/tiancaiamao/repos","events_url":"https://api.github.com/users/tiancaiamao/events{/privacy}","received_events_url":"https://api.github.com/users/tiancaiamao/received_events","type":"User","site_admin":false},"body":"I guess you need `time.After` instead of `time.Tick`","created_at":"2018-12-19T02:48:08Z","updated_at":"2018-12-19T02:57:46Z","html_url":"https://github.com/pingcap/tidb/pull/8711#discussion_r242776857","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/8711","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/242776857"},"html":{"href":"https://github.com/pingcap/tidb/pull/8711#discussion_r242776857"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/8711"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/8711","id":239069000,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5MDY5MDAw","html_url":"https://github.com/pingcap/tidb/pull/8711","diff_url":"https://github.com/pingcap/tidb/pull/8711.diff","patch_url":"https://github.com/pingcap/tidb/pull/8711.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/8711","number":8711,"state":"open","locked":false,"title":"server: try graceful close connection first","user":{"login":"crazycs520","id":26020263,"node_id":"MDQ6VXNlcjI2MDIwMjYz","avatar_url":"https://avatars2.githubusercontent.com/u/26020263?v=4","gravatar_id":"","url":"https://api.github.com/users/crazycs520","html_url":"https://github.com/crazycs520","followers_url":"https://api.github.com/users/crazycs520/followers","following_url":"https://api.github.com/users/crazycs520/following{/other_user}","gists_url":"https://api.github.com/users/crazycs520/gists{/gist_id}","starred_url":"https://api.github.com/users/crazycs520/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crazycs520/subscriptions","organizations_url":"https://api.github.com/users/crazycs520/orgs","repos_url":"https://api.github.com/users/crazycs520/repos","events_url":"https://api.github.com/users/crazycs520/events{/privacy}","received_events_url":"https://api.github.com/users/crazycs520/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for contributing to TiDB! Please read TiDB's [CONTRIBUTING](https://github.com/pingcap/tidb/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add issue link with summary if exists-->\r\nAnsible uses `terminal` signal to upgrade TiDB.\r\nCurrently TiDB will close all connection directly when got `terminal` signal.\r\n\r\nThis PR make TiDB try to firstly graceful close all connection with a timeout. If timeout, directly closes all connection.\r\n\r\n### What is changed and how it works?\r\n\r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n\r\n\r\nCode changes\r\n\r\n - Has exported function/method change\r\n\r\nSide effects\r\n\r\n \r\nRelated changes\r\n\r\n - Need to cherry-pick to the release branch\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/pingcap/tidb/8711)\n<!-- Reviewable:end -->\n","created_at":"2018-12-17T09:01:05Z","updated_at":"2018-12-19T02:57:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2d077115be9450b9dc1aaef93ca7b967d342cd1","assignee":null,"assignees":[],"requested_reviewers":[{"login":"winkyao","id":6949944,"node_id":"MDQ6VXNlcjY5NDk5NDQ=","avatar_url":"https://avatars0.githubusercontent.com/u/6949944?v=4","gravatar_id":"","url":"https://api.github.com/users/winkyao","html_url":"https://github.com/winkyao","followers_url":"https://api.github.com/users/winkyao/followers","following_url":"https://api.github.com/users/winkyao/following{/other_user}","gists_url":"https://api.github.com/users/winkyao/gists{/gist_id}","starred_url":"https://api.github.com/users/winkyao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winkyao/subscriptions","organizations_url":"https://api.github.com/users/winkyao/orgs","repos_url":"https://api.github.com/users/winkyao/repos","events_url":"https://api.github.com/users/winkyao/events{/privacy}","received_events_url":"https://api.github.com/users/winkyao/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1095620003,"node_id":"MDU6TGFiZWwxMDk1NjIwMDAz","url":"https://api.github.com/repos/pingcap/tidb/labels/component/server","name":"component/server","color":"e0854c","default":false},{"id":256872088,"node_id":"MDU6TGFiZWwyNTY4NzIwODg=","url":"https://api.github.com/repos/pingcap/tidb/labels/type/enhancement","name":"type/enhancement","color":"84b6eb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/8711/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/8711/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/8711/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/11105d1283571528fb319d3c7c5dbb084de2fce9","head":{"label":"crazycs520:try-gracefull-exit","ref":"try-gracefull-exit","sha":"11105d1283571528fb319d3c7c5dbb084de2fce9","user":{"login":"crazycs520","id":26020263,"node_id":"MDQ6VXNlcjI2MDIwMjYz","avatar_url":"https://avatars2.githubusercontent.com/u/26020263?v=4","gravatar_id":"","url":"https://api.github.com/users/crazycs520","html_url":"https://github.com/crazycs520","followers_url":"https://api.github.com/users/crazycs520/followers","following_url":"https://api.github.com/users/crazycs520/following{/other_user}","gists_url":"https://api.github.com/users/crazycs520/gists{/gist_id}","starred_url":"https://api.github.com/users/crazycs520/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crazycs520/subscriptions","organizations_url":"https://api.github.com/users/crazycs520/orgs","repos_url":"https://api.github.com/users/crazycs520/repos","events_url":"https://api.github.com/users/crazycs520/events{/privacy}","received_events_url":"https://api.github.com/users/crazycs520/received_events","type":"User","site_admin":false},"repo":{"id":136926865,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY5MjY4NjU=","name":"tidb","full_name":"crazycs520/tidb","private":false,"owner":{"login":"crazycs520","id":26020263,"node_id":"MDQ6VXNlcjI2MDIwMjYz","avatar_url":"https://avatars2.githubusercontent.com/u/26020263?v=4","gravatar_id":"","url":"https://api.github.com/users/crazycs520","html_url":"https://github.com/crazycs520","followers_url":"https://api.github.com/users/crazycs520/followers","following_url":"https://api.github.com/users/crazycs520/following{/other_user}","gists_url":"https://api.github.com/users/crazycs520/gists{/gist_id}","starred_url":"https://api.github.com/users/crazycs520/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crazycs520/subscriptions","organizations_url":"https://api.github.com/users/crazycs520/orgs","repos_url":"https://api.github.com/users/crazycs520/repos","events_url":"https://api.github.com/users/crazycs520/events{/privacy}","received_events_url":"https://api.github.com/users/crazycs520/received_events","type":"User","site_admin":false},"html_url":"https://github.com/crazycs520/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":true,"url":"https://api.github.com/repos/crazycs520/tidb","forks_url":"https://api.github.com/repos/crazycs520/tidb/forks","keys_url":"https://api.github.com/repos/crazycs520/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crazycs520/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crazycs520/tidb/teams","hooks_url":"https://api.github.com/repos/crazycs520/tidb/hooks","issue_events_url":"https://api.github.com/repos/crazycs520/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/crazycs520/tidb/events","assignees_url":"https://api.github.com/repos/crazycs520/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/crazycs520/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/crazycs520/tidb/tags","blobs_url":"https://api.github.com/repos/crazycs520/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crazycs520/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crazycs520/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/crazycs520/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crazycs520/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/crazycs520/tidb/languages","stargazers_url":"https://api.github.com/repos/crazycs520/tidb/stargazers","contributors_url":"https://api.github.com/repos/crazycs520/tidb/contributors","subscribers_url":"https://api.github.com/repos/crazycs520/tidb/subscribers","subscription_url":"https://api.github.com/repos/crazycs520/tidb/subscription","commits_url":"https://api.github.com/repos/crazycs520/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/crazycs520/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/crazycs520/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/crazycs520/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/crazycs520/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/crazycs520/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crazycs520/tidb/merges","archive_url":"https://api.github.com/repos/crazycs520/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crazycs520/tidb/downloads","issues_url":"https://api.github.com/repos/crazycs520/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/crazycs520/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/crazycs520/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/crazycs520/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crazycs520/tidb/labels{/name}","releases_url":"https://api.github.com/repos/crazycs520/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/crazycs520/tidb/deployments","created_at":"2018-06-11T13:00:28Z","updated_at":"2018-06-11T13:00:33Z","pushed_at":"2018-12-18T17:14:28Z","git_url":"git://github.com/crazycs520/tidb.git","ssh_url":"git@github.com:crazycs520/tidb.git","clone_url":"https://github.com/crazycs520/tidb.git","svn_url":"https://github.com/crazycs520/tidb","homepage":"https://pingcap.com","size":68864,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"e5b9fc079a9fbea9965faf14716f86332bf015e6","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"node_id":"MDEwOlJlcG9zaXRvcnk0MTk4NjM2OQ==","name":"tidb","full_name":"pingcap/tidb","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb/deployments","created_at":"2015-09-06T04:01:52Z","updated_at":"2018-12-19T02:40:32Z","pushed_at":"2018-12-19T02:54:47Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"https://pingcap.com","size":120730,"stargazers_count":16431,"watchers_count":16431,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2345,"mirror_url":null,"archived":false,"open_issues_count":622,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2345,"open_issues":622,"watchers":16431,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/8711"},"html":{"href":"https://github.com/pingcap/tidb/pull/8711"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/8711"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/8711/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/8711/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/8711/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/11105d1283571528fb319d3c7c5dbb084de2fce9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"tiancaiamao"}}