Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete leveldb before exit function #791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/utils/meta_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ void CheckChunkserverMeta(const std::vector<std::string>& store_path_list) {
options.create_if_missing = true;
leveldb::DB* metadb;
leveldb::Status s = leveldb::DB::Open(options, path + "/meta/", &metadb);
meta_dbs[path] = metadb;
if (!s.ok()) {
LOG(ERROR, "[MetaCheck] Open meta on %s failed: %s", path.c_str(), s.ToString().c_str());
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
return;
}
Expand All @@ -56,19 +58,20 @@ void CheckChunkserverMeta(const std::vector<std::string>& store_path_list) {
LOG(INFO, "[MetaCheck] %s Load meta version %d", path.c_str(), cur_version);
if (meta_version != EMPTY_META && cur_version != meta_version) {
LOG(ERROR, "Cannot handle this situation!!!");
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}
meta_version = cur_version;
} else if (s.IsNotFound()) {
if (meta_version != EMPTY_META && meta_version != 0) {
LOG(ERROR, "Cannot handle this situation!!!");
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}
meta_version = 0;
LOG(INFO, "No meta version %s", path.c_str());
}
}
meta_dbs[path] = metadb;
}
if (meta_version == CHUNKSERVER_META_VERSION) {
LOG(INFO, "[MetaCheck] Chunkserver meta check pass");
Expand All @@ -78,6 +81,7 @@ void CheckChunkserverMeta(const std::vector<std::string>& store_path_list) {
ChunkserverMetaV02V1(meta_dbs);
} else {
LOG(ERROR, "[MetaCheck] Cannot handle this situation!!!");
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}
SetChunkserverMetaVersion(meta_dbs);
Expand Down Expand Up @@ -106,6 +110,7 @@ void ChunkserverMetaV02V1(const std::map<std::string, leveldb::DB*>& meta_dbs) {
}
if (!src_meta) {
LOG(ERROR, "[MetaCheck] Cannot find a valid meta store");
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}

Expand All @@ -114,6 +119,7 @@ void ChunkserverMetaV02V1(const std::map<std::string, leveldb::DB*>& meta_dbs) {
BlockMeta meta;
if (!meta.ParseFromArray(it->value().data(), it->value().size())) {
LOG(ERROR, "[MetaCheck] Parse BlockMeta failed: key = %s", it->key().ToString().c_str());
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}
const std::string& path = meta.store_path();
Expand Down Expand Up @@ -146,6 +152,7 @@ void SetChunkserverMetaVersion(const std::map<std::string, leveldb::DB*>& meta_d
leveldb::Status s = ldb->Put(leveldb::WriteOptions(), meta_key, meta_str);
if (!s.ok()) {
LOG(ERROR, "[MetaCheck] Put meta failed %s", it->first.c_str());
CloseMetaStore(meta_dbs);
exit(EXIT_FAILURE);
}
LOG(INFO, "[MetaCheck] Set meta version %s = %d", it->first.c_str(), CHUNKSERVER_META_VERSION);
Expand All @@ -159,4 +166,4 @@ void CloseMetaStore(const std::map<std::string, leveldb::DB*>& meta_dbs) {
}

} // namespace bfs
} // namespace baidu
} // namespace baidu