From 8cc636951132c2ee93e32bfc999777e3da023dd7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 9 Oct 2018 09:13:41 -0500 Subject: [PATCH] ceph-kvstore-tool: rename repair -> destructive-repair This is shown to corrupt otherwise healthy rocksdb databases. Rename to make it clear that it is generally not safe to run and shoud only be used as a last resort. Signed-off-by: Sage Weil --- PendingReleaseNotes | 4 ++++ doc/man/8/ceph-kvstore-tool.rst | 6 ++++-- qa/workunits/cephtool/test_kvstore_tool.sh | 4 ++-- src/test/cli/ceph-kvstore-tool/help.t | 2 +- src/tools/ceph_kvstore_tool.cc | 16 +++++++++------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 1ca362d57563c..07fe31ada1cfa 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -97,6 +97,10 @@ ceph auth caps client.bad osd 'allow rwx pool foo' +* The ``ceph-kvstore-tool`` ``repair`` command has been renamed + ``destructive-repair`` since we have discovered it can corrupt an + otherwise healthy rocksdb database. It should be used only as a last-ditch + attempt to recover data from an otherwise corrupted store. diff --git a/doc/man/8/ceph-kvstore-tool.rst b/doc/man/8/ceph-kvstore-tool.rst index da53d9ce34267..7ef0ab3e2b9f1 100644 --- a/doc/man/8/ceph-kvstore-tool.rst +++ b/doc/man/8/ceph-kvstore-tool.rst @@ -72,8 +72,10 @@ which are as follows: :command:`compact-range ` Compact some entries specified by the URL encoded prefix and range. -:command:`repair` - Try to repair the kvstore. +:command:`destructive-repair` + Make a (potentially destructive) effort to recover a corrupted database. + Note that in the case of rocksdb this may corrupt an otherwise uncorrupted + database--use this only as a last resort! Availability ============ diff --git a/qa/workunits/cephtool/test_kvstore_tool.sh b/qa/workunits/cephtool/test_kvstore_tool.sh index b52f3b2a6726d..b7953dd216950 100755 --- a/qa/workunits/cephtool/test_kvstore_tool.sh +++ b/qa/workunits/cephtool/test_kvstore_tool.sh @@ -59,8 +59,8 @@ function test_ceph_kvstore_tool() # compact ceph-kvstore-tool bluestore-kv ${TEMP_DIR} compact - # repair - ceph-kvstore-tool bluestore-kv ${TEMP_DIR} repair + # destructive-repair + ceph-kvstore-tool bluestore-kv ${TEMP_DIR} destructive-repair current_kv_nums=`ceph-kvstore-tool bluestore-kv ${TEMP_DIR} list 2>/dev/null | wc -l` test ${origin_kv_nums} -eq ${current_kv_nums} diff --git a/src/test/cli/ceph-kvstore-tool/help.t b/src/test/cli/ceph-kvstore-tool/help.t index eab57fdb5bc3f..0d6041a44bfd2 100644 --- a/src/test/cli/ceph-kvstore-tool/help.t +++ b/src/test/cli/ceph-kvstore-tool/help.t @@ -16,5 +16,5 @@ compact compact-prefix compact-range - repair + destructive-repair (use only as last resort! may corrupt healthy data) diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 0496025291ec7..4198f09a5d2b5 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -285,7 +285,7 @@ class StoreTool db->compact_range(prefix, start, end); } - int repair() { + int destructive_repair() { return db->repair(std::cout); } }; @@ -309,7 +309,7 @@ void usage(const char *pname) << " compact\n" << " compact-prefix \n" << " compact-range \n" - << " repair\n" + << " destructive-repair (use only as last resort! may corrupt healthy data)\n" << std::endl; } @@ -355,15 +355,17 @@ int main(int argc, const char *argv[]) return 1; } - bool need_open_db = (cmd != "repair"); + bool need_open_db = (cmd != "destructive-repair"); StoreTool st(type, path, need_open_db); - if (cmd == "repair") { - int ret = st.repair(); + if (cmd == "destructive-repair") { + int ret = st.destructive_repair(); if (!ret) { - std::cout << "repair kvstore successfully" << std::endl; + std::cout << "destructive-repair completed without reporting an error" + << std::endl; } else { - std::cout << "repair kvstore failed" << std::endl; + std::cout << "destructive-repair failed with " << cpp_strerror(ret) + << std::endl; } return ret; } else if (cmd == "list" || cmd == "list-crc") { -- 2.39.5