Printing IO Error in DumpDBFileSummary (#9940)

Summary:
Right now in DumpDBFileSummary, IO error isn't printed out, but they are sometimes helpful. Print it out instead.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9940

Test Plan: Watch existing tests to pass.

Reviewed By: riversand963

Differential Revision: D36113016

fbshipit-source-id: 13002080fa4dc76589e2c1c5a1079df8a3c9391c
main
sdong 3 years ago committed by Facebook GitHub Bot
parent bf68d1c93d
commit 68ac507f96
  1. 44
      db/db_info_dumper.cc

@ -35,10 +35,12 @@ void DumpDBFileSummary(const ImmutableDBOptions& options,
Header(options.info_log, "DB SUMMARY\n"); Header(options.info_log, "DB SUMMARY\n");
Header(options.info_log, "DB Session ID: %s\n", session_id.c_str()); Header(options.info_log, "DB Session ID: %s\n", session_id.c_str());
Status s;
// Get files in dbname dir // Get files in dbname dir
if (!env->GetChildren(dbname, &files).ok()) { s = env->GetChildren(dbname, &files);
Error(options.info_log, if (!s.ok()) {
"Error when reading %s dir\n", dbname.c_str()); Error(options.info_log, "Error when reading %s dir %s\n", dbname.c_str(),
s.ToString().c_str());
} }
std::sort(files.begin(), files.end()); std::sort(files.begin(), files.end());
for (const std::string& file : files) { for (const std::string& file : files) {
@ -53,24 +55,27 @@ void DumpDBFileSummary(const ImmutableDBOptions& options,
Header(options.info_log, "IDENTITY file: %s\n", file.c_str()); Header(options.info_log, "IDENTITY file: %s\n", file.c_str());
break; break;
case kDescriptorFile: case kDescriptorFile:
if (env->GetFileSize(dbname + "/" + file, &file_size).ok()) { s = env->GetFileSize(dbname + "/" + file, &file_size);
if (s.ok()) {
Header(options.info_log, Header(options.info_log,
"MANIFEST file: %s size: %" PRIu64 " Bytes\n", file.c_str(), "MANIFEST file: %s size: %" PRIu64 " Bytes\n", file.c_str(),
file_size); file_size);
} else { } else {
Error(options.info_log, "Error when reading MANIFEST file: %s/%s\n", Error(options.info_log,
dbname.c_str(), file.c_str()); "Error when reading MANIFEST file: %s/%s %s\n", dbname.c_str(),
file.c_str(), s.ToString().c_str());
} }
break; break;
case kWalFile: case kWalFile:
if (env->GetFileSize(dbname + "/" + file, &file_size).ok()) { s = env->GetFileSize(dbname + "/" + file, &file_size);
if (s.ok()) {
wal_info.append(file) wal_info.append(file)
.append(" size: ") .append(" size: ")
.append(std::to_string(file_size)) .append(std::to_string(file_size))
.append(" ; "); .append(" ; ");
} else { } else {
Error(options.info_log, "Error when reading LOG file: %s/%s\n", Error(options.info_log, "Error when reading LOG file: %s/%s %s\n",
dbname.c_str(), file.c_str()); dbname.c_str(), file.c_str(), s.ToString().c_str());
} }
break; break;
case kTableFile: case kTableFile:
@ -86,10 +91,10 @@ void DumpDBFileSummary(const ImmutableDBOptions& options,
// Get sst files in db_path dir // Get sst files in db_path dir
for (auto& db_path : options.db_paths) { for (auto& db_path : options.db_paths) {
if (dbname.compare(db_path.path) != 0) { if (dbname.compare(db_path.path) != 0) {
if (!env->GetChildren(db_path.path, &files).ok()) { s = env->GetChildren(db_path.path, &files);
Error(options.info_log, if (!s.ok()) {
"Error when reading %s dir\n", Error(options.info_log, "Error when reading %s dir %s\n",
db_path.path.c_str()); db_path.path.c_str(), s.ToString().c_str());
continue; continue;
} }
std::sort(files.begin(), files.end()); std::sort(files.begin(), files.end());
@ -111,22 +116,25 @@ void DumpDBFileSummary(const ImmutableDBOptions& options,
// Get wal file in wal_dir // Get wal file in wal_dir
const auto& wal_dir = options.GetWalDir(dbname); const auto& wal_dir = options.GetWalDir(dbname);
if (!options.IsWalDirSameAsDBPath(dbname)) { if (!options.IsWalDirSameAsDBPath(dbname)) {
if (!env->GetChildren(wal_dir, &files).ok()) { s = env->GetChildren(wal_dir, &files);
Error(options.info_log, "Error when reading %s dir\n", wal_dir.c_str()); if (!s.ok()) {
Error(options.info_log, "Error when reading %s dir %s\n", wal_dir.c_str(),
s.ToString().c_str());
return; return;
} }
wal_info.clear(); wal_info.clear();
for (const std::string& file : files) { for (const std::string& file : files) {
if (ParseFileName(file, &number, &type)) { if (ParseFileName(file, &number, &type)) {
if (type == kWalFile) { if (type == kWalFile) {
if (env->GetFileSize(wal_dir + "/" + file, &file_size).ok()) { s = env->GetFileSize(wal_dir + "/" + file, &file_size);
if (s.ok()) {
wal_info.append(file) wal_info.append(file)
.append(" size: ") .append(" size: ")
.append(std::to_string(file_size)) .append(std::to_string(file_size))
.append(" ; "); .append(" ; ");
} else { } else {
Error(options.info_log, "Error when reading LOG file %s/%s\n", Error(options.info_log, "Error when reading LOG file %s/%s %s\n",
wal_dir.c_str(), file.c_str()); wal_dir.c_str(), file.c_str(), s.ToString().c_str());
} }
} }
} }

Loading…
Cancel
Save