{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/comments/111531619","pull_request_review_id":32785098,"id":111531619,"diff_hunk":"@@ -149,6 +149,57 @@ fn test_retry_async() {\n }\n \n #[test]\n+fn test_restart_leader() {\n+    let eps = vec![\n+        \"http://127.0.0.1:42978\".to_owned(),\n+        \"http://127.0.0.1:52978\".to_owned(),\n+        \"http://127.0.0.1:62978\".to_owned(),\n+    ];\n+\n+    // Service has only one GetMembersResponse, so the leader never changes.\n+    let se = Arc::new(Service::new(eps.clone()));\n+    // Start mock servers.\n+    let _server_a = MockServer::run(\"127.0.0.1:42978\", se.clone(), Some(se.clone()));\n+    let _server_b = MockServer::run(\"127.0.0.1:52978\", se.clone(), Some(se.clone()));\n+    let _server_c = MockServer::run(\"127.0.0.1:62978\", se.clone(), Some(se.clone()));\n+\n+    thread::sleep(Duration::from_secs(1));\n+\n+    let client = RpcClient::new(&eps[0]).unwrap();\n+    // Put a region.\n+    let store_id = client.alloc_id().unwrap();\n+    let mut store = metapb::Store::new();\n+    store.set_id(store_id);\n+\n+    let peer_id = client.alloc_id().unwrap();\n+    let mut peer = metapb::Peer::new();\n+    peer.set_id(peer_id);\n+    peer.set_store_id(store_id);\n+\n+    let region_id = client.alloc_id().unwrap();\n+    let mut region = metapb::Region::new();\n+    region.set_id(region_id);\n+    region.mut_peers().push(peer);\n+    client.bootstrap_cluster(store.clone(), region.clone()).unwrap();\n+\n+    let region = client.get_region_by_id(1);\n+    region.wait().unwrap();\n+\n+    // Kill servers.\n+    drop(_server_a);\n+    drop(_server_b);\n+    drop(_server_c);\n+    // Restart them again.\n+    let _server_a = MockServer::run(\"127.0.0.1:42978\", se.clone(), Some(se.clone()));\n+    let _server_b = MockServer::run(\"127.0.0.1:52978\", se.clone(), Some(se.clone()));\n+    let _server_c = MockServer::run(\"127.0.0.1:62978\", se.clone(), Some(se.clone()));\n+    thread::sleep(Duration::from_secs(1));\n+\n+    let region = client.get_region_by_id(1);\n+    region.wait().unwrap();","path":"tests/pd/test_rpc_client.rs","position":51,"original_position":51,"commit_id":"4856ae6305c54cdb0695d0eb8b49d4119d170e2f","original_commit_id":"4856ae6305c54cdb0695d0eb8b49d4119d170e2f","user":{"login":"BusyJay","id":1701473,"avatar_url":"https://avatars0.githubusercontent.com/u/1701473?v=3","gravatar_id":"","url":"https://api.github.com/users/BusyJay","html_url":"https://github.com/BusyJay","followers_url":"https://api.github.com/users/BusyJay/followers","following_url":"https://api.github.com/users/BusyJay/following{/other_user}","gists_url":"https://api.github.com/users/BusyJay/gists{/gist_id}","starred_url":"https://api.github.com/users/BusyJay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BusyJay/subscriptions","organizations_url":"https://api.github.com/users/BusyJay/orgs","repos_url":"https://api.github.com/users/BusyJay/repos","events_url":"https://api.github.com/users/BusyJay/events{/privacy}","received_events_url":"https://api.github.com/users/BusyJay/received_events","type":"User","site_admin":false},"body":"How to verify that the client is reconnected to remote again?","created_at":"2017-04-14T05:37:08Z","updated_at":"2017-04-14T05:37:15Z","html_url":"https://github.com/pingcap/tikv/pull/1759#discussion_r111531619","pull_request_url":"https://api.github.com/repos/pingcap/tikv/pulls/1759","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments/111531619"},"html":{"href":"https://github.com/pingcap/tikv/pull/1759#discussion_r111531619"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1759"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/1759","id":115482201,"html_url":"https://github.com/pingcap/tikv/pull/1759","diff_url":"https://github.com/pingcap/tikv/pull/1759.diff","patch_url":"https://github.com/pingcap/tikv/pull/1759.patch","issue_url":"https://api.github.com/repos/pingcap/tikv/issues/1759","number":1759,"state":"open","locked":false,"title":"pd: always update client","user":{"login":"overvenus","id":2150711,"avatar_url":"https://avatars3.githubusercontent.com/u/2150711?v=3","gravatar_id":"","url":"https://api.github.com/users/overvenus","html_url":"https://github.com/overvenus","followers_url":"https://api.github.com/users/overvenus/followers","following_url":"https://api.github.com/users/overvenus/following{/other_user}","gists_url":"https://api.github.com/users/overvenus/gists{/gist_id}","starred_url":"https://api.github.com/users/overvenus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overvenus/subscriptions","organizations_url":"https://api.github.com/users/overvenus/orgs","repos_url":"https://api.github.com/users/overvenus/repos","events_url":"https://api.github.com/users/overvenus/events{/privacy}","received_events_url":"https://api.github.com/users/overvenus/received_events","type":"User","site_admin":false},"body":"For one node PD cluster, tikv pd client will fail to make a request if the pd leader restarts. Similarly, if the member response doesn't change, tikv pd client will always skip updating the inner grpc client.\r\n\r\n\r\nPTAL @siddontang @nolouch @BusyJay @zhangjinpeng1987 ","created_at":"2017-04-12T07:48:50Z","updated_at":"2017-04-14T05:37:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d1f79b90bff3e31e7b5b800f7d8cc95aae0b0da","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv/pulls/1759/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv/pulls/1759/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv/issues/1759/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/4856ae6305c54cdb0695d0eb8b49d4119d170e2f","head":{"label":"pingcap:ov/always-update","ref":"ov/always-update","sha":"4856ae6305c54cdb0695d0eb8b49d4119d170e2f","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","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":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","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},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-04-14T03:44:38Z","pushed_at":"2017-04-14T05:36:31Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"","size":7782,"stargazers_count":1726,"watchers_count":1726,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":163,"mirror_url":null,"open_issues_count":101,"forks":163,"open_issues":101,"watchers":1726,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"3cf1bf7b23a4be01bb13923e9c144f99d38bc2d6","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","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":48833910,"name":"tikv","full_name":"pingcap/tikv","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars0.githubusercontent.com/u/11855343?v=3","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},"private":false,"html_url":"https://github.com/pingcap/tikv","description":"Distributed transactional key value database powered by Rust and Raft","fork":false,"url":"https://api.github.com/repos/pingcap/tikv","forks_url":"https://api.github.com/repos/pingcap/tikv/forks","keys_url":"https://api.github.com/repos/pingcap/tikv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tikv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tikv/teams","hooks_url":"https://api.github.com/repos/pingcap/tikv/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tikv/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tikv/events","assignees_url":"https://api.github.com/repos/pingcap/tikv/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tikv/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tikv/tags","blobs_url":"https://api.github.com/repos/pingcap/tikv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tikv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tikv/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tikv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tikv/languages","stargazers_url":"https://api.github.com/repos/pingcap/tikv/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tikv/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tikv/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tikv/subscription","commits_url":"https://api.github.com/repos/pingcap/tikv/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tikv/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tikv/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tikv/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tikv/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tikv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tikv/merges","archive_url":"https://api.github.com/repos/pingcap/tikv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tikv/downloads","issues_url":"https://api.github.com/repos/pingcap/tikv/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tikv/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tikv/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tikv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tikv/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tikv/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tikv/deployments","created_at":"2015-12-31T04:51:32Z","updated_at":"2017-04-14T03:44:38Z","pushed_at":"2017-04-14T05:36:31Z","git_url":"git://github.com/pingcap/tikv.git","ssh_url":"git@github.com:pingcap/tikv.git","clone_url":"https://github.com/pingcap/tikv.git","svn_url":"https://github.com/pingcap/tikv","homepage":"","size":7782,"stargazers_count":1726,"watchers_count":1726,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":163,"mirror_url":null,"open_issues_count":101,"forks":163,"open_issues":101,"watchers":1726,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1759"},"html":{"href":"https://github.com/pingcap/tikv/pull/1759"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1759"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1759/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1759/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1759/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv/statuses/4856ae6305c54cdb0695d0eb8b49d4119d170e2f"}}}}
{"actor":{"display_login":"BusyJay"}}