From 4b622ab0f2afa5c068ae6650a5d3da5d830d617d Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Mon, 19 Nov 2012 11:54:13 -0800 Subject: [PATCH] Enhance manifest_dump to print each individual edit. Summary: The manifest file contains a series of edits. If the verbose option is switched on, then print each individual edit in the manifest file. This helps in debugging. Test Plan: make clean manifest_dump Reviewers: emayanke, sheki Reviewed By: sheki CC: leveldb Differential Revision: https://reviews.facebook.net/D6807 --- db/version_set.cc | 11 ++++++++++- db/version_set.h | 3 ++- tools/manifest_dump.cc | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/db/version_set.cc b/db/version_set.cc index f8c4d71e5..0882f9f4a 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -1099,7 +1099,8 @@ Status VersionSet::Recover() { return s; } -Status VersionSet::DumpManifest(Options& options, std::string& dscname) { +Status VersionSet::DumpManifest(Options& options, std::string& dscname, + bool verbose) { struct LogReporter : public log::Reader::Reporter { Status* status; virtual void Corruption(size_t bytes, const Status& s) { @@ -1122,6 +1123,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname) { uint64_t last_sequence = 0; uint64_t log_number = 0; uint64_t prev_log_number = 0; + int count = 0; VersionSet::Builder builder(this, current_); { @@ -1142,6 +1144,13 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname) { } } + // Write out each individual edit + if (verbose) { + printf("*************************Edit[%d] = %s\n", + count, edit.DebugString().c_str()); + } + count++; + if (s.ok()) { builder.Apply(&edit); } diff --git a/db/version_set.h b/db/version_set.h index fa216623d..56b8be1a5 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -286,7 +286,8 @@ class VersionSet { const char* LevelSummary(LevelSummaryStorage* scratch) const; // printf contents (for debugging) - Status DumpManifest(Options& options, std::string& manifestFileName); + Status DumpManifest(Options& options, std::string& manifestFileName, + bool verbose); // Return a human-readable short (single-line) summary of the data size // of files per level. Uses *scratch as backing store. diff --git a/tools/manifest_dump.cc b/tools/manifest_dump.cc index d8b0a9e0c..2cdf8c7fe 100644 --- a/tools/manifest_dump.cc +++ b/tools/manifest_dump.cc @@ -60,7 +60,7 @@ int main(int argc, char** argv) { VersionSet* versions = new VersionSet(dbname, &options, tc, cmp); - Status s = versions->DumpManifest(options, file); + Status s = versions->DumpManifest(options, file, verbose); if (!s.ok()) { printf("Error in processing file %s %s\n", manifestfile.c_str(), s.ToString().c_str());