{"action":"created","comment":{"url":"https://api.github.com/repos/baidu/tera/pulls/comments/53283842","id":53283842,"diff_hunk":"@@ -3257,6 +3268,111 @@ void MasterImpl::ClearUnusedSnapshots(TabletPtr tablet, const TabletMeta& meta)\n     }\n }\n \n+void MasterImpl::UpdateSchemaCallback(std::string table_name,\n+                                      std::string tablet_path,\n+                                      std::string start_key,\n+                                      std::string end_key,\n+                                      int32_t retry_times,\n+                                      UpdateRequest* request,\n+                                      UpdateResponse* response,\n+                                      bool rpc_failed, int status_code) {\n+    StatusCode status = response->status();\n+    delete request;\n+    delete response;\n+    TabletPtr tablet;\n+    if (!m_tablet_manager->FindTablet(table_name, start_key, &tablet)\n+        || (tablet->GetKeyEnd() != end_key)) {\n+        LOG(INFO) << \"[update] tablet not found, ignore it:\" << tablet_path\n+            << \", start_key:\" << DebugString(start_key)\n+            << \", end_key:\" << DebugString(end_key);\n+        return;\n+    }\n+\n+    // fail\n+    if (rpc_failed || (status != kTabletNodeOk)) {\n+        if (rpc_failed) {\n+            LOG(WARNING) << \"[update] fail to update schema: \"\n+                << sofa::pbrpc::RpcErrorCodeToString(status_code)\n+                << \": \" << tablet;\n+        } else {\n+            LOG(WARNING) << \"[update] fail to update schema: \" << StatusCodeToString(status)\n+                << \": \" << tablet;\n+        }\n+        if (retry_times > FLAGS_tera_master_schema_update_retry_times) {\n+            LOG(ERROR) << \"[update] retry \" << retry_times << \" times, kick \"\n+                << tablet->GetServerAddr();\n+            TryKickTabletNode(tablet->GetServerAddr());\n+        } else {\n+            UpdateClosure* done =\n+                NewClosure(this, &MasterImpl::UpdateSchemaCallback, tablet->GetTableName(),\n+                           tablet->GetPath(), tablet->GetKeyStart(), tablet->GetKeyEnd(), retry_times + 1);\n+            ThreadPool::Task task =\n+                boost::bind(&MasterImpl::NoticeTabletNodeSchemaUpdatedAsync, this, tablet, done);\n+            m_thread_pool->DelayTask(FLAGS_tera_master_schema_update_retry_period * 1000, task);\n+        }\n+        return;\n+    }\n+    LOG(INFO) << \"[update] tablet schema update done. \" << tablet;\n+    tablet->SetSchemaIsSyncing(false);\n+    TablePtr table = tablet->GetTable();\n+    if (!table->AddToRange(tablet->GetKeyStart(), tablet->GetKeyEnd())) {\n+        LOG(ERROR) << \"[update] invalid argument:\" << tablet;\n+    }\n+    if (table->IsCompleteRange()) {\n+        table->UpdateRpcDone();\n+        LOG(INFO) << \"[update] DONE :\" << table;\n+        // new schema synced to all tablets/ts\n+        table->SetSchemaIsSyncing(false);","path":"src/master/master_impl.cc","position":83,"original_position":83,"commit_id":"08e635362c6f119d56e698539b773eda1cf87751","original_commit_id":"08e635362c6f119d56e698539b773eda1cf87751","user":{"login":"00k","id":9716419,"avatar_url":"https://avatars.githubusercontent.com/u/9716419?v=3","gravatar_id":"","url":"https://api.github.com/users/00k","html_url":"https://github.com/00k","followers_url":"https://api.github.com/users/00k/followers","following_url":"https://api.github.com/users/00k/following{/other_user}","gists_url":"https://api.github.com/users/00k/gists{/gist_id}","starred_url":"https://api.github.com/users/00k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/00k/subscriptions","organizations_url":"https://api.github.com/users/00k/orgs","repos_url":"https://api.github.com/users/00k/repos","events_url":"https://api.github.com/users/00k/events{/privacy}","received_events_url":"https://api.github.com/users/00k/received_events","type":"User","site_admin":false},"body":"这两个都是同时调用，合成一个函数","created_at":"2016-02-18T08:31:42Z","updated_at":"2016-02-18T08:31:42Z","html_url":"https://github.com/baidu/tera/pull/689#discussion_r53283842","pull_request_url":"https://api.github.com/repos/baidu/tera/pulls/689","_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments/53283842"},"html":{"href":"https://github.com/baidu/tera/pull/689#discussion_r53283842"},"pull_request":{"href":"https://api.github.com/repos/baidu/tera/pulls/689"}}},"pull_request":{"url":"https://api.github.com/repos/baidu/tera/pulls/689","id":55459133,"html_url":"https://github.com/baidu/tera/pull/689","diff_url":"https://github.com/baidu/tera/pull/689.diff","patch_url":"https://github.com/baidu/tera/pull/689.patch","issue_url":"https://api.github.com/repos/baidu/tera/issues/689","number":689,"state":"open","locked":false,"title":"issue=#437 Master notice ts schema updated","user":{"login":"taocp","id":5194281,"avatar_url":"https://avatars.githubusercontent.com/u/5194281?v=3","gravatar_id":"","url":"https://api.github.com/users/taocp","html_url":"https://github.com/taocp","followers_url":"https://api.github.com/users/taocp/followers","following_url":"https://api.github.com/users/taocp/following{/other_user}","gists_url":"https://api.github.com/users/taocp/gists{/gist_id}","starred_url":"https://api.github.com/users/taocp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taocp/subscriptions","organizations_url":"https://api.github.com/users/taocp/orgs","repos_url":"https://api.github.com/users/taocp/repos","events_url":"https://api.github.com/users/taocp/events{/privacy}","received_events_url":"https://api.github.com/users/taocp/received_events","type":"User","site_admin":false},"body":"#437 ","created_at":"2016-01-08T13:01:52Z","updated_at":"2016-02-18T08:31:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e359ec032dffcaa0cf879443eda8d9451920927","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/baidu/tera/pulls/689/commits","review_comments_url":"https://api.github.com/repos/baidu/tera/pulls/689/comments","review_comment_url":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baidu/tera/issues/689/comments","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/08e635362c6f119d56e698539b773eda1cf87751","head":{"label":"taocp:master-notice-ts-schema-updated","ref":"master-notice-ts-schema-updated","sha":"08e635362c6f119d56e698539b773eda1cf87751","user":{"login":"taocp","id":5194281,"avatar_url":"https://avatars.githubusercontent.com/u/5194281?v=3","gravatar_id":"","url":"https://api.github.com/users/taocp","html_url":"https://github.com/taocp","followers_url":"https://api.github.com/users/taocp/followers","following_url":"https://api.github.com/users/taocp/following{/other_user}","gists_url":"https://api.github.com/users/taocp/gists{/gist_id}","starred_url":"https://api.github.com/users/taocp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taocp/subscriptions","organizations_url":"https://api.github.com/users/taocp/orgs","repos_url":"https://api.github.com/users/taocp/repos","events_url":"https://api.github.com/users/taocp/events{/privacy}","received_events_url":"https://api.github.com/users/taocp/received_events","type":"User","site_admin":false},"repo":{"id":32839075,"name":"tera","full_name":"taocp/tera","owner":{"login":"taocp","id":5194281,"avatar_url":"https://avatars.githubusercontent.com/u/5194281?v=3","gravatar_id":"","url":"https://api.github.com/users/taocp","html_url":"https://github.com/taocp","followers_url":"https://api.github.com/users/taocp/followers","following_url":"https://api.github.com/users/taocp/following{/other_user}","gists_url":"https://api.github.com/users/taocp/gists{/gist_id}","starred_url":"https://api.github.com/users/taocp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taocp/subscriptions","organizations_url":"https://api.github.com/users/taocp/orgs","repos_url":"https://api.github.com/users/taocp/repos","events_url":"https://api.github.com/users/taocp/events{/privacy}","received_events_url":"https://api.github.com/users/taocp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/taocp/tera","description":" A distributed, elastic, structured database.","fork":true,"url":"https://api.github.com/repos/taocp/tera","forks_url":"https://api.github.com/repos/taocp/tera/forks","keys_url":"https://api.github.com/repos/taocp/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/taocp/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/taocp/tera/teams","hooks_url":"https://api.github.com/repos/taocp/tera/hooks","issue_events_url":"https://api.github.com/repos/taocp/tera/issues/events{/number}","events_url":"https://api.github.com/repos/taocp/tera/events","assignees_url":"https://api.github.com/repos/taocp/tera/assignees{/user}","branches_url":"https://api.github.com/repos/taocp/tera/branches{/branch}","tags_url":"https://api.github.com/repos/taocp/tera/tags","blobs_url":"https://api.github.com/repos/taocp/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/taocp/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/taocp/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/taocp/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/taocp/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/taocp/tera/languages","stargazers_url":"https://api.github.com/repos/taocp/tera/stargazers","contributors_url":"https://api.github.com/repos/taocp/tera/contributors","subscribers_url":"https://api.github.com/repos/taocp/tera/subscribers","subscription_url":"https://api.github.com/repos/taocp/tera/subscription","commits_url":"https://api.github.com/repos/taocp/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/taocp/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/taocp/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/taocp/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/taocp/tera/contents/{+path}","compare_url":"https://api.github.com/repos/taocp/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/taocp/tera/merges","archive_url":"https://api.github.com/repos/taocp/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/taocp/tera/downloads","issues_url":"https://api.github.com/repos/taocp/tera/issues{/number}","pulls_url":"https://api.github.com/repos/taocp/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/taocp/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/taocp/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/taocp/tera/labels{/name}","releases_url":"https://api.github.com/repos/taocp/tera/releases{/id}","deployments_url":"https://api.github.com/repos/taocp/tera/deployments","created_at":"2015-03-25T02:57:20Z","updated_at":"2016-01-17T14:03:26Z","pushed_at":"2016-02-04T09:11:18Z","git_url":"git://github.com/taocp/tera.git","ssh_url":"git@github.com:taocp/tera.git","clone_url":"https://github.com/taocp/tera.git","svn_url":"https://github.com/taocp/tera","homepage":"","size":12690,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"baidu:master","ref":"master","sha":"bafc62d5c5d4ecfff0f2e96cb8341a2728ade2c2","user":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"repo":{"id":18129915,"name":"tera","full_name":"baidu/tera","owner":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baidu/tera","description":"A distributed, elastic, structured database.","fork":false,"url":"https://api.github.com/repos/baidu/tera","forks_url":"https://api.github.com/repos/baidu/tera/forks","keys_url":"https://api.github.com/repos/baidu/tera/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baidu/tera/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baidu/tera/teams","hooks_url":"https://api.github.com/repos/baidu/tera/hooks","issue_events_url":"https://api.github.com/repos/baidu/tera/issues/events{/number}","events_url":"https://api.github.com/repos/baidu/tera/events","assignees_url":"https://api.github.com/repos/baidu/tera/assignees{/user}","branches_url":"https://api.github.com/repos/baidu/tera/branches{/branch}","tags_url":"https://api.github.com/repos/baidu/tera/tags","blobs_url":"https://api.github.com/repos/baidu/tera/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baidu/tera/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baidu/tera/git/refs{/sha}","trees_url":"https://api.github.com/repos/baidu/tera/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/{sha}","languages_url":"https://api.github.com/repos/baidu/tera/languages","stargazers_url":"https://api.github.com/repos/baidu/tera/stargazers","contributors_url":"https://api.github.com/repos/baidu/tera/contributors","subscribers_url":"https://api.github.com/repos/baidu/tera/subscribers","subscription_url":"https://api.github.com/repos/baidu/tera/subscription","commits_url":"https://api.github.com/repos/baidu/tera/commits{/sha}","git_commits_url":"https://api.github.com/repos/baidu/tera/git/commits{/sha}","comments_url":"https://api.github.com/repos/baidu/tera/comments{/number}","issue_comment_url":"https://api.github.com/repos/baidu/tera/issues/comments{/number}","contents_url":"https://api.github.com/repos/baidu/tera/contents/{+path}","compare_url":"https://api.github.com/repos/baidu/tera/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baidu/tera/merges","archive_url":"https://api.github.com/repos/baidu/tera/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baidu/tera/downloads","issues_url":"https://api.github.com/repos/baidu/tera/issues{/number}","pulls_url":"https://api.github.com/repos/baidu/tera/pulls{/number}","milestones_url":"https://api.github.com/repos/baidu/tera/milestones{/number}","notifications_url":"https://api.github.com/repos/baidu/tera/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baidu/tera/labels{/name}","releases_url":"https://api.github.com/repos/baidu/tera/releases{/id}","deployments_url":"https://api.github.com/repos/baidu/tera/deployments","created_at":"2014-03-26T07:22:05Z","updated_at":"2016-02-16T04:01:58Z","pushed_at":"2016-02-15T06:00:40Z","git_url":"git://github.com/baidu/tera.git","ssh_url":"git@github.com:baidu/tera.git","clone_url":"https://github.com/baidu/tera.git","svn_url":"https://github.com/baidu/tera","homepage":"","size":16430,"stargazers_count":355,"watchers_count":355,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":119,"mirror_url":null,"open_issues_count":140,"forks":119,"open_issues":140,"watchers":355,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/689"},"html":{"href":"https://github.com/baidu/tera/pull/689"},"issue":{"href":"https://api.github.com/repos/baidu/tera/issues/689"},"comments":{"href":"https://api.github.com/repos/baidu/tera/issues/689/comments"},"review_comments":{"href":"https://api.github.com/repos/baidu/tera/pulls/689/comments"},"review_comment":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baidu/tera/pulls/689/commits"},"statuses":{"href":"https://api.github.com/repos/baidu/tera/statuses/08e635362c6f119d56e698539b773eda1cf87751"}}}}