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
This commit is contained in:
parent
e91ebf1399
commit
6a2be31f14
@ -23,8 +23,8 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto* env = options.env;
|
auto* env = options.env;
|
||||||
uint64_t number;
|
uint64_t number = 0;
|
||||||
FileType type;
|
FileType type = kInfoLogFile;
|
||||||
|
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
uint64_t file_num = 0;
|
uint64_t file_num = 0;
|
||||||
@ -38,7 +38,9 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
|
|||||||
}
|
}
|
||||||
std::sort(files.begin(), files.end());
|
std::sort(files.begin(), files.end());
|
||||||
for (std::string file : files) {
|
for (std::string file : files) {
|
||||||
ParseFileName(file, &number, &type);
|
if (!ParseFileName(file, &number, &type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case kCurrentFile:
|
case kCurrentFile:
|
||||||
Log(options.info_log, "CURRENT file: %s\n", file.c_str());
|
Log(options.info_log, "CURRENT file: %s\n", file.c_str());
|
||||||
@ -78,9 +80,10 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
|
|||||||
}
|
}
|
||||||
std::sort(files.begin(), files.end());
|
std::sort(files.begin(), files.end());
|
||||||
for (std::string file : files) {
|
for (std::string file : files) {
|
||||||
ParseFileName(file, &number, &type);
|
if (ParseFileName(file, &number, &type)) {
|
||||||
if (type == kTableFile && ++file_num < 10) {
|
if (type == kTableFile && ++file_num < 10) {
|
||||||
file_info.append(file).append(" ");
|
file_info.append(file).append(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,13 +102,14 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
|
|||||||
}
|
}
|
||||||
wal_info.clear();
|
wal_info.clear();
|
||||||
for (std::string file : files) {
|
for (std::string file : files) {
|
||||||
ParseFileName(file, &number, &type);
|
if (ParseFileName(file, &number, &type)) {
|
||||||
if (type == kLogFile) {
|
if (type == kLogFile) {
|
||||||
env->GetFileSize(options.wal_dir + "/" + file, &file_size);
|
env->GetFileSize(options.wal_dir + "/" + file, &file_size);
|
||||||
char str[8];
|
char str[8];
|
||||||
snprintf(str, sizeof(str), "%lu", file_size);
|
snprintf(str, sizeof(str), "%lu", file_size);
|
||||||
wal_info.append(file).append(" size: ").
|
wal_info.append(file).append(" size: ").
|
||||||
append(str, sizeof(str)).append(" ;");
|
append(str, sizeof(str)).append(" ;");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user