提交 6a2be31f 编写于 作者: F Feng Zhu

fix_valgrind_error_caused_in_db_info_dummper

Summary: 1. add default value to FileType type, thus avoid valgrind error

Test Plan: valgrind ./db_test

Reviewers: sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21807
上级 e91ebf13
......@@ -23,8 +23,8 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
auto* env = options.env;
uint64_t number;
FileType type;
uint64_t number = 0;
FileType type = kInfoLogFile;
std::vector<std::string> files;
uint64_t file_num = 0;
......@@ -38,7 +38,9 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
std::sort(files.begin(), files.end());
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (!ParseFileName(file, &number, &type)) {
continue;
}
switch (type) {
case kCurrentFile:
Log(options.info_log, "CURRENT file: %s\n", file.c_str());
......@@ -78,12 +80,13 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
std::sort(files.begin(), files.end());
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (ParseFileName(file, &number, &type)) {
if (type == kTableFile && ++file_num < 10) {
file_info.append(file).append(" ");
}
}
}
}
Log(options.info_log, "SST files in %s dir, Total Num: %lu, files: %s\n",
db_path.path.c_str(), file_num, file_info.c_str());
file_num = 0;
......@@ -99,7 +102,7 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
wal_info.clear();
for (std::string file : files) {
ParseFileName(file, &number, &type);
if (ParseFileName(file, &number, &type)) {
if (type == kLogFile) {
env->GetFileSize(options.wal_dir + "/" + file, &file_size);
char str[8];
......@@ -109,6 +112,7 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
}
}
}
}
Log(options.info_log, "Write Ahead Log file in %s: %s\n",
options.wal_dir.c_str(), wal_info.c_str());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册