{"action":"opened","number":1250,"pull_request":{"url":"https://api.github.com/repos/pingcap/pd/pulls/1250","id":216560827,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTYwODI3","html_url":"https://github.com/pingcap/pd/pull/1250","diff_url":"https://github.com/pingcap/pd/pull/1250.diff","patch_url":"https://github.com/pingcap/pd/pull/1250.patch","issue_url":"https://api.github.com/repos/pingcap/pd/issues/1250","number":1250,"state":"open","locked":false,"title":"Fix panic of adjacent-region-scheduler after pd transfer leader","user":{"login":"lerencao","id":1456096,"node_id":"MDQ6VXNlcjE0NTYwOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1456096?v=4","gravatar_id":"","url":"https://api.github.com/users/lerencao","html_url":"https://github.com/lerencao","followers_url":"https://api.github.com/users/lerencao/followers","following_url":"https://api.github.com/users/lerencao/following{/other_user}","gists_url":"https://api.github.com/users/lerencao/gists{/gist_id}","starred_url":"https://api.github.com/users/lerencao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lerencao/subscriptions","organizations_url":"https://api.github.com/users/lerencao/orgs","repos_url":"https://api.github.com/users/lerencao/repos","events_url":"https://api.github.com/users/lerencao/events{/privacy}","received_events_url":"https://api.github.com/users/lerencao/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for working on PD! Please read PD's [CONTRIBUTING](https://github.com/pingcap/pd/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add the issue link with summary if it exists-->\r\n\r\nIf `adjacent-region` scheduler is enabled, after pd transfers leader and the new leader is prepared, \r\nthere is a gap that heartbeats of some regions are not received, and leaders are not updated.\r\n\r\nstore id of a nil peer  is `0`, see https://github.com/pingcap/pd/blob/fa5f08c252a4c5025cdef5bf0f2bdab78d7c0a36/vendor/github.com/pingcap/kvproto/pkg/metapb/metapb.pb.go#L256, so this line https://github.com/pingcap/pd/blob/fa5f08c252a4c5025cdef5bf0f2bdab78d7c0a36/server/schedulers/adjacent_region.go#L223 return a `nil` store, which causes panic.\r\n\r\n### What is changed and how it works?\r\n\r\nThis change makes sure that region's leader is not nil, and leader's store is not nil, and also fix metric value of adjacent-count.\r\n\r\nAnother solution is  skip holes of not heartbeat-ed regions when calculating adjacent-regions, which prevents the issue at front.\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`make test`\r\n\r\nNo side effects\r\n","created_at":"2018-09-19T08:51:29Z","updated_at":"2018-09-19T08:51:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/pd/pulls/1250/commits","review_comments_url":"https://api.github.com/repos/pingcap/pd/pulls/1250/comments","review_comment_url":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/pd/issues/1250/comments","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/dc0fcbc8e11aaaba054736ea60f8deef598aa988","head":{"label":"lerencao:fix/adjacent-region-panic","ref":"fix/adjacent-region-panic","sha":"dc0fcbc8e11aaaba054736ea60f8deef598aa988","user":{"login":"lerencao","id":1456096,"node_id":"MDQ6VXNlcjE0NTYwOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1456096?v=4","gravatar_id":"","url":"https://api.github.com/users/lerencao","html_url":"https://github.com/lerencao","followers_url":"https://api.github.com/users/lerencao/followers","following_url":"https://api.github.com/users/lerencao/following{/other_user}","gists_url":"https://api.github.com/users/lerencao/gists{/gist_id}","starred_url":"https://api.github.com/users/lerencao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lerencao/subscriptions","organizations_url":"https://api.github.com/users/lerencao/orgs","repos_url":"https://api.github.com/users/lerencao/repos","events_url":"https://api.github.com/users/lerencao/events{/privacy}","received_events_url":"https://api.github.com/users/lerencao/received_events","type":"User","site_admin":false},"repo":{"id":122902827,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI5MDI4Mjc=","name":"pd","full_name":"lerencao/pd","private":false,"owner":{"login":"lerencao","id":1456096,"node_id":"MDQ6VXNlcjE0NTYwOTY=","avatar_url":"https://avatars1.githubusercontent.com/u/1456096?v=4","gravatar_id":"","url":"https://api.github.com/users/lerencao","html_url":"https://github.com/lerencao","followers_url":"https://api.github.com/users/lerencao/followers","following_url":"https://api.github.com/users/lerencao/following{/other_user}","gists_url":"https://api.github.com/users/lerencao/gists{/gist_id}","starred_url":"https://api.github.com/users/lerencao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lerencao/subscriptions","organizations_url":"https://api.github.com/users/lerencao/orgs","repos_url":"https://api.github.com/users/lerencao/repos","events_url":"https://api.github.com/users/lerencao/events{/privacy}","received_events_url":"https://api.github.com/users/lerencao/received_events","type":"User","site_admin":false},"html_url":"https://github.com/lerencao/pd","description":"Placement driver for TiKV","fork":true,"url":"https://api.github.com/repos/lerencao/pd","forks_url":"https://api.github.com/repos/lerencao/pd/forks","keys_url":"https://api.github.com/repos/lerencao/pd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lerencao/pd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lerencao/pd/teams","hooks_url":"https://api.github.com/repos/lerencao/pd/hooks","issue_events_url":"https://api.github.com/repos/lerencao/pd/issues/events{/number}","events_url":"https://api.github.com/repos/lerencao/pd/events","assignees_url":"https://api.github.com/repos/lerencao/pd/assignees{/user}","branches_url":"https://api.github.com/repos/lerencao/pd/branches{/branch}","tags_url":"https://api.github.com/repos/lerencao/pd/tags","blobs_url":"https://api.github.com/repos/lerencao/pd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lerencao/pd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lerencao/pd/git/refs{/sha}","trees_url":"https://api.github.com/repos/lerencao/pd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lerencao/pd/statuses/{sha}","languages_url":"https://api.github.com/repos/lerencao/pd/languages","stargazers_url":"https://api.github.com/repos/lerencao/pd/stargazers","contributors_url":"https://api.github.com/repos/lerencao/pd/contributors","subscribers_url":"https://api.github.com/repos/lerencao/pd/subscribers","subscription_url":"https://api.github.com/repos/lerencao/pd/subscription","commits_url":"https://api.github.com/repos/lerencao/pd/commits{/sha}","git_commits_url":"https://api.github.com/repos/lerencao/pd/git/commits{/sha}","comments_url":"https://api.github.com/repos/lerencao/pd/comments{/number}","issue_comment_url":"https://api.github.com/repos/lerencao/pd/issues/comments{/number}","contents_url":"https://api.github.com/repos/lerencao/pd/contents/{+path}","compare_url":"https://api.github.com/repos/lerencao/pd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lerencao/pd/merges","archive_url":"https://api.github.com/repos/lerencao/pd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lerencao/pd/downloads","issues_url":"https://api.github.com/repos/lerencao/pd/issues{/number}","pulls_url":"https://api.github.com/repos/lerencao/pd/pulls{/number}","milestones_url":"https://api.github.com/repos/lerencao/pd/milestones{/number}","notifications_url":"https://api.github.com/repos/lerencao/pd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lerencao/pd/labels{/name}","releases_url":"https://api.github.com/repos/lerencao/pd/releases{/id}","deployments_url":"https://api.github.com/repos/lerencao/pd/deployments","created_at":"2018-02-26T02:42:29Z","updated_at":"2018-09-19T08:25:18Z","pushed_at":"2018-09-19T08:25:14Z","git_url":"git://github.com/lerencao/pd.git","ssh_url":"git@github.com:lerencao/pd.git","clone_url":"https://github.com/lerencao/pd.git","svn_url":"https://github.com/lerencao/pd","homepage":"","size":11853,"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":"fa5f08c252a4c5025cdef5bf0f2bdab78d7c0a36","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":53311716,"node_id":"MDEwOlJlcG9zaXRvcnk1MzMxMTcxNg==","name":"pd","full_name":"pingcap/pd","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/pd","description":"Placement driver for TiKV","fork":false,"url":"https://api.github.com/repos/pingcap/pd","forks_url":"https://api.github.com/repos/pingcap/pd/forks","keys_url":"https://api.github.com/repos/pingcap/pd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/pd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/pd/teams","hooks_url":"https://api.github.com/repos/pingcap/pd/hooks","issue_events_url":"https://api.github.com/repos/pingcap/pd/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/pd/events","assignees_url":"https://api.github.com/repos/pingcap/pd/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/pd/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/pd/tags","blobs_url":"https://api.github.com/repos/pingcap/pd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/pd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/pd/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/pd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/pd/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/pd/languages","stargazers_url":"https://api.github.com/repos/pingcap/pd/stargazers","contributors_url":"https://api.github.com/repos/pingcap/pd/contributors","subscribers_url":"https://api.github.com/repos/pingcap/pd/subscribers","subscription_url":"https://api.github.com/repos/pingcap/pd/subscription","commits_url":"https://api.github.com/repos/pingcap/pd/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/pd/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/pd/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/pd/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/pd/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/pd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/pd/merges","archive_url":"https://api.github.com/repos/pingcap/pd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/pd/downloads","issues_url":"https://api.github.com/repos/pingcap/pd/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/pd/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/pd/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/pd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/pd/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/pd/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/pd/deployments","created_at":"2016-03-07T09:13:06Z","updated_at":"2018-09-17T10:04:21Z","pushed_at":"2018-09-17T10:04:19Z","git_url":"git://github.com/pingcap/pd.git","ssh_url":"git@github.com:pingcap/pd.git","clone_url":"https://github.com/pingcap/pd.git","svn_url":"https://github.com/pingcap/pd","homepage":"","size":12234,"stargazers_count":243,"watchers_count":243,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"archived":false,"open_issues_count":42,"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":156,"open_issues":42,"watchers":243,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/pd/pulls/1250"},"html":{"href":"https://github.com/pingcap/pd/pull/1250"},"issue":{"href":"https://api.github.com/repos/pingcap/pd/issues/1250"},"comments":{"href":"https://api.github.com/repos/pingcap/pd/issues/1250/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/pd/pulls/1250/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/pd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/pd/pulls/1250/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/pd/statuses/dc0fcbc8e11aaaba054736ea60f8deef598aa988"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":2,"additions":7,"deletions":2,"changed_files":1}}
{"actor":{"display_login":"lerencao"}}