{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/182413613","pull_request_review_id":113202266,"id":182413613,"diff_hunk":"@@ -1282,14 +1289,37 @@ func (s *session) loadCommonGlobalVariablesIfNeeded() error {\n \t\t// When running bootstrap or upgrade, we should not access global storage.\n \t\treturn nil\n \t}\n-\t// Set the variable to true to prevent cyclic recursive call.\n-\tvars.CommonGlobalLoaded = true\n-\trows, fields, err := s.ExecRestrictedSQL(s, loadCommonGlobalVarsSQL)\n-\tif err != nil {\n-\t\tvars.CommonGlobalLoaded = false\n-\t\tlog.Errorf(\"Failed to load common global variables.\")\n-\t\treturn errors.Trace(err)\n+\n+\tvar rows []types.Row\n+\tvar fields []*ast.ResultField\n+\tvar err error\n+\n+\tnow := time.Now()\n+\tglobalVariableCache.RLock()","path":"session/session.go","position":31,"original_position":31,"commit_id":"ad5dc7fc9afd4dd5e2198dca0ac4544a768e000d","original_commit_id":"ad5dc7fc9afd4dd5e2198dca0ac4544a768e000d","user":{"login":"ngaut","id":878009,"avatar_url":"https://avatars2.githubusercontent.com/u/878009?v=4","gravatar_id":"","url":"https://api.github.com/users/ngaut","html_url":"https://github.com/ngaut","followers_url":"https://api.github.com/users/ngaut/followers","following_url":"https://api.github.com/users/ngaut/following{/other_user}","gists_url":"https://api.github.com/users/ngaut/gists{/gist_id}","starred_url":"https://api.github.com/users/ngaut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngaut/subscriptions","organizations_url":"https://api.github.com/users/ngaut/orgs","repos_url":"https://api.github.com/users/ngaut/repos","events_url":"https://api.github.com/users/ngaut/events{/privacy}","received_events_url":"https://api.github.com/users/ngaut/received_events","type":"User","site_admin":false},"body":"Extract to a function or method.","created_at":"2018-04-18T12:50:01Z","updated_at":"2018-04-18T12:50:01Z","html_url":"https://github.com/pingcap/tidb/pull/6315#discussion_r182413613","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/6315","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/182413613"},"html":{"href":"https://github.com/pingcap/tidb/pull/6315#discussion_r182413613"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/6315"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/6315","id":182467116,"html_url":"https://github.com/pingcap/tidb/pull/6315","diff_url":"https://github.com/pingcap/tidb/pull/6315.diff","patch_url":"https://github.com/pingcap/tidb/pull/6315.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/6315","number":6315,"state":"open","locked":false,"title":"session: cache global variable for a short while","user":{"login":"tiancaiamao","id":1420062,"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":"When there are a lot of connections come to TiDB simultaneously, load\r\nglobal variable would make TiKV meta region overload.\r\nWe can cache global variable for a short while to avoid this problem.\r\n\r\n@coocood  @shenli ","created_at":"2018-04-18T12:46:22Z","updated_at":"2018-04-18T12:50:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4d29460103bf0a3d6124c8e33c874388e8ab496","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/6315/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/6315/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/6315/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/ad5dc7fc9afd4dd5e2198dca0ac4544a768e000d","head":{"label":"tiancaiamao:cache-global-variable","ref":"cache-global-variable","sha":"ad5dc7fc9afd4dd5e2198dca0ac4544a768e000d","user":{"login":"tiancaiamao","id":1420062,"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},"repo":{"id":63065396,"name":"tidb","full_name":"tiancaiamao/tidb","owner":{"login":"tiancaiamao","id":1420062,"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},"private":false,"html_url":"https://github.com/tiancaiamao/tidb","description":"TiDB is a distributed NewSQL database compatible with MySQL protocol ","fork":true,"url":"https://api.github.com/repos/tiancaiamao/tidb","forks_url":"https://api.github.com/repos/tiancaiamao/tidb/forks","keys_url":"https://api.github.com/repos/tiancaiamao/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tiancaiamao/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tiancaiamao/tidb/teams","hooks_url":"https://api.github.com/repos/tiancaiamao/tidb/hooks","issue_events_url":"https://api.github.com/repos/tiancaiamao/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/tiancaiamao/tidb/events","assignees_url":"https://api.github.com/repos/tiancaiamao/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/tiancaiamao/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/tiancaiamao/tidb/tags","blobs_url":"https://api.github.com/repos/tiancaiamao/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tiancaiamao/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tiancaiamao/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/tiancaiamao/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tiancaiamao/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/tiancaiamao/tidb/languages","stargazers_url":"https://api.github.com/repos/tiancaiamao/tidb/stargazers","contributors_url":"https://api.github.com/repos/tiancaiamao/tidb/contributors","subscribers_url":"https://api.github.com/repos/tiancaiamao/tidb/subscribers","subscription_url":"https://api.github.com/repos/tiancaiamao/tidb/subscription","commits_url":"https://api.github.com/repos/tiancaiamao/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/tiancaiamao/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/tiancaiamao/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/tiancaiamao/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/tiancaiamao/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/tiancaiamao/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tiancaiamao/tidb/merges","archive_url":"https://api.github.com/repos/tiancaiamao/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tiancaiamao/tidb/downloads","issues_url":"https://api.github.com/repos/tiancaiamao/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/tiancaiamao/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/tiancaiamao/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/tiancaiamao/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tiancaiamao/tidb/labels{/name}","releases_url":"https://api.github.com/repos/tiancaiamao/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/tiancaiamao/tidb/deployments","created_at":"2016-07-11T12:20:13Z","updated_at":"2016-07-11T12:20:15Z","pushed_at":"2018-04-18T12:45:20Z","git_url":"git://github.com/tiancaiamao/tidb.git","ssh_url":"git@github.com:tiancaiamao/tidb.git","clone_url":"https://github.com/tiancaiamao/tidb.git","svn_url":"https://github.com/tiancaiamao/tidb","homepage":"","size":44727,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"cc8c38d6d819d9114bb2267a1bba85a2dd6f9095","user":{"login":"pingcap","id":11855343,"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,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"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},"private":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-04-18T12:37:12Z","pushed_at":"2018-04-18T12:46:23Z","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":70423,"stargazers_count":12726,"watchers_count":12726,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1736,"mirror_url":null,"archived":false,"open_issues_count":380,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1736,"open_issues":380,"watchers":12726,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/6315"},"html":{"href":"https://github.com/pingcap/tidb/pull/6315"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/6315"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/6315/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/6315/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/6315/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/ad5dc7fc9afd4dd5e2198dca0ac4544a768e000d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ngaut"}}