{"action":"created","comment":{"url":"https://api.github.com/repos/baidu/tera/pulls/comments/86936402","pull_request_review_id":7566808,"id":86936402,"diff_hunk":"@@ -1134,21 +1135,68 @@ Status VersionSet::ReadCurrentFile(uint64_t tablet, std::string* dscname ) {\n   std::string current;\n   s = ReadFileToString(env_, CurrentFileName(pdbname), &current);\n   if (!s.ok()) {\n-    Log(options_->info_log, \"[%s] current file lost: %s.\",\n+    Log(options_->info_log, \"[%s] read CURRENT failed: %s.\",\n         dbname_.c_str(), CurrentFileName(pdbname).c_str());\n+    if (!options_->ignore_corruption_in_open) {\n+      return Status::IOError(\"read CURRENT failed\");\n+    }\n   } else if (current.empty() || current[current.size()-1] != '\\n') {\n     Log(options_->info_log, \"[%s] current file error: %s, content:\\\"%s\\\", size:%lu.\",\n         dbname_.c_str(), CurrentFileName(pdbname).c_str(),\n         current.c_str(), current.size());\n-    ArchiveFile(env_, CurrentFileName(pdbname));\n+    if (!options_->ignore_corruption_in_open) {\n+      return Status::IOError(\"read CURRENT failed\");\n+    } else {\n+      ArchiveFile(env_, CurrentFileName(pdbname));\n+    }\n   } else {\n     current.resize(current.size() - 1);\n     *dscname = pdbname + \"/\" + current;\n   }\n \n+  if (!s.ok()) {\n+    // fail to read CURRENT\n+\n+    s = env_->FileStatus(CurrentFileName(pdbname));\n+    if (!s.IsNotFound()) {\n+      // CURRENT exists but failed to read, maybe timeout\n+      return Status::IOError(\"read CURRENT failed\");\n+    } else {\n+      // do nothing in here\n+      // CURRENT lost, try to find the lastest manifest if ignore_corruption_in_open\n+    }\n+  }\n+\n+  // if program runs to here, there are only 2 possibilities\n+  // 1). read CURRENT success\n+  // 2). CURRENT lost\n+  assert(s.ok() || s.IsNotFound());\n+\n+  Status manifest_status = env_->FileStatus(*dscname);\n+  if (!manifest_status.ok() && !manifest_status.IsNotFound()) {\n+    return Status::IOError(\"status of manifest the CURRENT pointed to is unknown\");\n+  }\n+  // status of manifest is deterministic\n+\n+  if (manifest_status.ok()) {","path":"src/leveldb/db/version_set.cc","position":59,"original_position":59,"commit_id":"4e7c70f5ba715b43a0648bebba17325fe52a6b77","original_commit_id":"4e7c70f5ba715b43a0648bebba17325fe52a6b77","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":"这个判断跟1176换个顺序，可以更优雅","created_at":"2016-11-08T07:32:31Z","updated_at":"2016-11-08T07:38:59Z","html_url":"https://github.com/baidu/tera/pull/1033#discussion_r86936402","pull_request_url":"https://api.github.com/repos/baidu/tera/pulls/1033","_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments/86936402"},"html":{"href":"https://github.com/baidu/tera/pull/1033#discussion_r86936402"},"pull_request":{"href":"https://api.github.com/repos/baidu/tera/pulls/1033"}}},"pull_request":{"url":"https://api.github.com/repos/baidu/tera/pulls/1033","id":88829611,"html_url":"https://github.com/baidu/tera/pull/1033","diff_url":"https://github.com/baidu/tera/pull/1033.diff","patch_url":"https://github.com/baidu/tera/pull/1033.patch","issue_url":"https://api.github.com/repos/baidu/tera/issues/1033","number":1033,"state":"open","locked":false,"title":"issue=#1028 load.leveldb-open","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":"#1028\n1. Load的逻辑和原来一致，只是增加了对错误的处理、取消部分自动容错（100行代码改动，集中在src/leveldb/db/db_impl.cc）\n2. 增加了MockEnv用以模拟环境异常（500行代码改动 src/leveldb/util/env_mock.cc ），目前支持在单机跑测试，所以TabletIO改了一点点，以方便模拟load行为。\n3. 针对这次的改动，增加了测试（500行代码改动 src/io/test/load_test.cc）\n\n本次逻辑改动只有100行，剩下1000行都是测试代码，不算违规吧。。\n\n自动化测试场景：\n1. current、manifest各自的丢失、读取失败、内容错误\n2. sst丢失导致load失败；sst丢失但开启有损load最后load成功\n","created_at":"2016-10-11T13:11:56Z","updated_at":"2016-11-08T07:38:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec7289dbb5f27b8ebbe1fb8bdf375163c17495eb","assignee":{"login":"lylei","id":2767333,"avatar_url":"https://avatars.githubusercontent.com/u/2767333?v=3","gravatar_id":"","url":"https://api.github.com/users/lylei","html_url":"https://github.com/lylei","followers_url":"https://api.github.com/users/lylei/followers","following_url":"https://api.github.com/users/lylei/following{/other_user}","gists_url":"https://api.github.com/users/lylei/gists{/gist_id}","starred_url":"https://api.github.com/users/lylei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lylei/subscriptions","organizations_url":"https://api.github.com/users/lylei/orgs","repos_url":"https://api.github.com/users/lylei/repos","events_url":"https://api.github.com/users/lylei/events{/privacy}","received_events_url":"https://api.github.com/users/lylei/received_events","type":"User","site_admin":false},"assignees":[{"login":"lylei","id":2767333,"avatar_url":"https://avatars.githubusercontent.com/u/2767333?v=3","gravatar_id":"","url":"https://api.github.com/users/lylei","html_url":"https://github.com/lylei","followers_url":"https://api.github.com/users/lylei/followers","following_url":"https://api.github.com/users/lylei/following{/other_user}","gists_url":"https://api.github.com/users/lylei/gists{/gist_id}","starred_url":"https://api.github.com/users/lylei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lylei/subscriptions","organizations_url":"https://api.github.com/users/lylei/orgs","repos_url":"https://api.github.com/users/lylei/repos","events_url":"https://api.github.com/users/lylei/events{/privacy}","received_events_url":"https://api.github.com/users/lylei/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/baidu/tera/pulls/1033/commits","review_comments_url":"https://api.github.com/repos/baidu/tera/pulls/1033/comments","review_comment_url":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baidu/tera/issues/1033/comments","statuses_url":"https://api.github.com/repos/baidu/tera/statuses/4e7c70f5ba715b43a0648bebba17325fe52a6b77","head":{"label":"taocp:load.leveldb-open","ref":"load.leveldb-open","sha":"4e7c70f5ba715b43a0648bebba17325fe52a6b77","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-10-28T03:18:19Z","pushed_at":"2016-11-07T10:41:41Z","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":13792,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"baidu:master","ref":"master","sha":"d5fb0878bd742549c9679685853f366dc22584b1","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":"An Internet-Scale 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-11-08T07:09:41Z","pushed_at":"2016-11-07T10:54:04Z","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":17902,"stargazers_count":651,"watchers_count":651,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":189,"mirror_url":null,"open_issues_count":143,"forks":189,"open_issues":143,"watchers":651,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baidu/tera/pulls/1033"},"html":{"href":"https://github.com/baidu/tera/pull/1033"},"issue":{"href":"https://api.github.com/repos/baidu/tera/issues/1033"},"comments":{"href":"https://api.github.com/repos/baidu/tera/issues/1033/comments"},"review_comments":{"href":"https://api.github.com/repos/baidu/tera/pulls/1033/comments"},"review_comment":{"href":"https://api.github.com/repos/baidu/tera/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baidu/tera/pulls/1033/commits"},"statuses":{"href":"https://api.github.com/repos/baidu/tera/statuses/4e7c70f5ba715b43a0648bebba17325fe52a6b77"}}}}
{"actor":{"display_login":"00k"}}