From a150604e101077c6910e6699219dad6d119fc302 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 18 Nov 2019 15:00:23 -0800 Subject: [PATCH] db_stress to cover total order seek (#6039) Summary: Right now, in db_stress, as long as prefix extractor is defined, TestIterator always uses. There is value of cover total_order_seek = true when prefix extractor is define. Add a small chance that this flag is turned on. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6039 Test Plan: Run the test for a while. Differential Revision: D18539689 fbshipit-source-id: 568790dd7789c9986b83764b870df0423a122d99 --- tools/db_stress_tool.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/db_stress_tool.cc b/tools/db_stress_tool.cc index d550bdf8d..66f17c3b6 100644 --- a/tools/db_stress_tool.cc +++ b/tools/db_stress_tool.cc @@ -2426,6 +2426,11 @@ class StressTest { ReadOptions readoptionscopy = read_opts; readoptionscopy.snapshot = snapshot; + if (thread->rand.OneIn(16)) { + // When prefix extractor is used, it's useful to cover total order seek. + readoptionscopy.total_order_seek = true; + } + std::string upper_bound_str; Slice upper_bound; if (thread->rand.OneIn(16)) { @@ -2585,7 +2590,8 @@ class StressTest { // Iterator is not valid. It can be legimate if it has already been // out of upper or lower bound, or filtered out by prefix iterator. const Slice& total_order_key = cmp_iter->key(); - const SliceTransform* pe = options_.prefix_extractor.get(); + const SliceTransform* pe = + ro.total_order_seek ? nullptr : options_.prefix_extractor.get(); const Comparator* cmp = options_.comparator; if (pe != nullptr) {