From 6258c5e5a9ec4f17ca9efb393db5960bd8890931 Mon Sep 17 00:00:00 2001 From: ideawu <3202758+ideawu@users.noreply.github.com> Date: Tue, 11 Feb 2020 12:16:39 +0800 Subject: [PATCH] ssdb-repair compact after repairing --- .gitignore | 1 + tools/ssdb-repair.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.gitignore b/.gitignore index 593eb4e94..36a546929 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ tools/leveldb-import _pack build_config.mk log.txt +repair.log log_slave.txt src/client/demo src/client/hello-ssdb diff --git a/tools/ssdb-repair.cpp b/tools/ssdb-repair.cpp index ea99ae82a..453ca0d83 100755 --- a/tools/ssdb-repair.cpp +++ b/tools/ssdb-repair.cpp @@ -65,6 +65,30 @@ int main(int argc, char **argv){ } printf("leveldb repaired.\n"); + + { + leveldb::DB* db; + leveldb::Options options; + leveldb::Status status; + options.create_if_missing = true; + options.write_buffer_size = 32 * 1024 * 1024; + options.compression = leveldb::kSnappyCompression; + + status = leveldb::DB::Open(options, leveldb_folder.c_str(), &db); + if(!status.ok()){ + fprintf(stderr, "ERROR: open leveldb: %s error!\n", leveldb_folder.c_str()); + exit(1); + } + printf("compacting data...\n"); + db->CompactRange(NULL, NULL); + + { + std::string val; + if(db->GetProperty("leveldb.stats", &val)){ + printf("%s\n", val.c_str()); + } + } + } return 0; }