From: Igor Fedotov Date: Thu, 27 Aug 2020 16:54:05 +0000 (+0300) Subject: kv/RocksDBStore: apply sharding recreate within a repair. X-Git-Tag: v16.1.0~1128^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=28c646794e5115350deca48cb4c4aa67e97b2eb7;p=ceph.git kv/RocksDBStore: apply sharding recreate within a repair. This way we avoid an invalid attempt to apply this in read-only mode. Signed-off-by: Igor Fedotov --- diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index df0a8019b50b..b2f8ef01d435 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -887,6 +887,7 @@ int RocksDBStore::do_open(ostream &out, &sharding_recreate_text); bool recreate_mode = status.ok() && sharding_recreate_text == "1"; + ceph_assert(!recreate_mode || !open_readonly); if (recreate_mode == false && missing_cfs.size() != 0) { derr << __func__ << " missing column families: " << missing_cfs_shard << dendl; return -EIO; @@ -895,9 +896,9 @@ int RocksDBStore::do_open(ostream &out, if (existing_cfs.empty()) { // no column families if (open_readonly) { - status = rocksdb::DB::Open(opt, path, &db); + status = rocksdb::DB::OpenForReadOnly(opt, path, &db); } else { - status = rocksdb::DB::OpenForReadOnly(opt, path, &db); + status = rocksdb::DB::Open(opt, path, &db); } if (!status.ok()) { derr << status.ToString() << dendl; @@ -1075,6 +1076,12 @@ int RocksDBStore::repair(std::ostream &out) derr << __func__ << " cannot write to " << sharding_recreate << dendl; return -1; } + // fiinalize sharding recreate + if (do_open(out, false, false)) { + derr << __func__ << " cannot finalize repair" << dendl; + return -1; + } + close(); } if (repaired && status.ok()) {