From: Haomai Wang Date: Fri, 10 Mar 2017 06:10:47 +0000 (+0800) Subject: kv/rocksdb: add option to control whether enable DeleteRange API X-Git-Tag: v12.0.2~282^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F13855%2Fhead;p=ceph.git kv/rocksdb: add option to control whether enable DeleteRange API Signed-off-by: Haomai Wang --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 2aa4f283b7eb..491322fd5c22 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -918,6 +918,7 @@ OPTION(rocksdb_perf, OPT_BOOL, false) // Enabling this will have 5-10% impact on OPTION(rocksdb_collect_compaction_stats, OPT_BOOL, false) //For rocksdb, this behavior will be an overhead of 5%~10%, collected only rocksdb_perf is enabled. OPTION(rocksdb_collect_extended_stats, OPT_BOOL, false) //For rocksdb, this behavior will be an overhead of 5%~10%, collected only rocksdb_perf is enabled. OPTION(rocksdb_collect_memory_stats, OPT_BOOL, false) //For rocksdb, this behavior will be an overhead of 5%~10%, collected only rocksdb_perf is enabled. +OPTION(rocksdb_enable_rmrange, OPT_BOOL, false) // see https://github.com/facebook/rocksdb/blob/master/include/rocksdb/db.h#L253 // rocksdb options that will be used for omap(if omap_backend is rocksdb) OPTION(filestore_rocksdb_options, OPT_STR, "") diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index 0d102c6e6d04..dd0895adf576 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -619,7 +619,19 @@ void RocksDBStore::RocksDBTransactionImpl::rm_range_keys(const string &prefix, const string &start, const string &end) { - bat.DeleteRange(combine_strings(prefix, start), combine_strings(prefix, end)); + if (db->enable_rmrange) { + bat.DeleteRange(combine_strings(prefix, start), combine_strings(prefix, end)); + } else { + auto it = db->get_iterator(prefix); + it->lower_bound(start); + while (it->valid()) { + if (it->key() >= end) { + break; + } + bat.Delete(combine_strings(prefix, it->key())); + it->next(); + } + } } void RocksDBStore::RocksDBTransactionImpl::merge( diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h index ef81df324961..4d25408a5f00 100644 --- a/src/kv/RocksDBStore.h +++ b/src/kv/RocksDBStore.h @@ -102,6 +102,7 @@ public: /// compact the underlying rocksdb store bool compact_on_mount; bool disableWAL; + bool enable_rmrange; void compact() override; int tryInterpret(const string key, const string val, rocksdb::Options &opt); @@ -135,7 +136,8 @@ public: compact_queue_stop(false), compact_thread(this), compact_on_mount(false), - disableWAL(false) + disableWAL(false), + enable_rmrange(cct->_conf->rocksdb_enable_rmrange) {} ~RocksDBStore() override;