]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/rocksdb: add option to control whether enable DeleteRange API 13855/head
authorHaomai Wang <haomai@xsky.com>
Fri, 10 Mar 2017 06:10:47 +0000 (14:10 +0800)
committerHaomai Wang <haomai@xsky.com>
Sun, 26 Mar 2017 18:56:57 +0000 (14:56 -0400)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/common/config_opts.h
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index 2aa4f283b7eb9cc06029bfe737c7aa3dbc38eb2f..491322fd5c227e40cb232e521ab70383a7212087 100644 (file)
@@ -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, "")
index 0d102c6e6d04dd59f02d8f6c397ddecd618111e4..dd0895adf57683599a660e22e279da81db0aa1d3 100644 (file)
@@ -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(
index ef81df324961bd2125e2102e2dba27827349e430..4d25408a5f00405afa03538db0017162c26d1fc8 100644 (file)
@@ -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;