{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/comments/89563482","pull_request_review_id":10108949,"id":89563482,"diff_hunk":"@@ -1043,11 +1115,37 @@ impl Peer {\n                uuid,\n                index);\n \n-        if cb.is_none() {\n+        if cmd_cb.is_none() {\n             return exec_result;\n         }\n \n-        let cb = cb.unwrap();\n+        let (cb, lease_renew_time) = cmd_cb.unwrap();\n+        // Try to renew the leader lease as this command asks to.\n+        if let Some(current_expired_time) = self.leader_lease_expired_time {\n+            // This peer is leader and has recorded leader lease.\n+            // Calculate the renewed lease for this command. If the renewed lease lives longer\n+            // than current leader lease, update the leader lease to the renewed lease.\n+            let next_expired_time = self.next_lease_expired_time(lease_renew_time);\n+            // Use the lease expired timestamp comparation here, so that these codes still","path":"src/raftstore/store/peer.rs","position":224,"original_position":224,"commit_id":"0df3ddef3b57e7d99374074ee49b8e09284ddbc8","original_commit_id":"0df3ddef3b57e7d99374074ee49b8e09284ddbc8","user":{"login":"queenypingcap","id":19528243,"avatar_url":"https://avatars.githubusercontent.com/u/19528243?v=3","gravatar_id":"","url":"https://api.github.com/users/queenypingcap","html_url":"https://github.com/queenypingcap","followers_url":"https://api.github.com/users/queenypingcap/followers","following_url":"https://api.github.com/users/queenypingcap/following{/other_user}","gists_url":"https://api.github.com/users/queenypingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/queenypingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/queenypingcap/subscriptions","organizations_url":"https://api.github.com/users/queenypingcap/orgs","repos_url":"https://api.github.com/users/queenypingcap/repos","events_url":"https://api.github.com/users/queenypingcap/events{/privacy}","received_events_url":"https://api.github.com/users/queenypingcap/received_events","type":"User","site_admin":false},"body":"Use the lease expired timestamp comparation here -> Use the lease expiring timestamp comparison here","created_at":"2016-11-25T04:22:34Z","updated_at":"2016-11-25T04:22:34Z","html_url":"https://github.com/pingcap/tikv/pull/1327#discussion_r89563482","pull_request_url":"https://api.github.com/repos/pingcap/tikv/pulls/1327","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments/89563482"},"html":{"href":"https://github.com/pingcap/tikv/pull/1327#discussion_r89563482"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1327"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tikv/pulls/1327","id":94547671,"html_url":"https://github.com/pingcap/tikv/pull/1327","diff_url":"https://github.com/pingcap/tikv/pull/1327.diff","patch_url":"https://github.com/pingcap/tikv/pull/1327.patch","issue_url":"https://api.github.com/repos/pingcap/tikv/issues/1327","number":1327,"state":"open","locked":false,"title":"raftstore: improve lease read","user":{"login":"hhkbp2","id":1933824,"avatar_url":"https://avatars.githubusercontent.com/u/1933824?v=3","gravatar_id":"","url":"https://api.github.com/users/hhkbp2","html_url":"https://github.com/hhkbp2","followers_url":"https://api.github.com/users/hhkbp2/followers","following_url":"https://api.github.com/users/hhkbp2/following{/other_user}","gists_url":"https://api.github.com/users/hhkbp2/gists{/gist_id}","starred_url":"https://api.github.com/users/hhkbp2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhkbp2/subscriptions","organizations_url":"https://api.github.com/users/hhkbp2/orgs","repos_url":"https://api.github.com/users/hhkbp2/repos","events_url":"https://api.github.com/users/hhkbp2/events{/privacy}","received_events_url":"https://api.github.com/users/hhkbp2/received_events","type":"User","site_admin":false},"body":"This PR tries to fix issue #964 \r\n\r\nIt uses monotonic clocktime to calculate the accurate leader lease. \r\nIf the leader holds the lease, it serve local read requests as lease reads. If the lease has expired, it serves local read requests and quorum read requests as consistent reads. All write requests are consistent.\r\nThe consistent read/write would be written to raft log and replicated to the raft quorum. Everytime a leader perform a consistent read/write, it will try to renew its leader lease.\r\n\r\nRelated to #1301, #1296.\r\n\r\nThe sysbench results show that the performance doesn't change significantly.\r\n","created_at":"2016-11-21T03:02:22Z","updated_at":"2016-11-25T04:22:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a70d1220a269f60ba90c841f91209c2873833952","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tikv/pulls/1327/commits","review_comments_url":"https://api.github.com/repos/pingcap/tikv/pulls/1327/comments","review_comment_url":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tikv/issues/1327/comments","statuses_url":"https://api.github.com/repos/pingcap/tikv/statuses/0df3ddef3b57e7d99374074ee49b8e09284ddbc8","head":{"label":"pingcap:hhkbp2/improve-lease-read","ref":"hhkbp2/improve-lease-read","sha":"0df3ddef3b57e7d99374074ee49b8e09284ddbc8","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.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://avatars.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":"2016-11-24T11:06:36Z","pushed_at":"2016-11-25T04:21:19Z","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":7623,"stargazers_count":1235,"watchers_count":1235,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":88,"forks":108,"open_issues":88,"watchers":1235,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"5f3c83639c9e10778a7a22aef114f923e57b5a09","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.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://avatars.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":"2016-11-24T11:06:36Z","pushed_at":"2016-11-25T04:21:19Z","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":7623,"stargazers_count":1235,"watchers_count":1235,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":88,"forks":108,"open_issues":88,"watchers":1235,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1327"},"html":{"href":"https://github.com/pingcap/tikv/pull/1327"},"issue":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1327"},"comments":{"href":"https://api.github.com/repos/pingcap/tikv/issues/1327/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1327/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tikv/pulls/1327/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tikv/statuses/0df3ddef3b57e7d99374074ee49b8e09284ddbc8"}}}}
{"actor":{"display_login":"queenypingcap"}}