From c53db172a166141fabd3ee49fef9c90dcab44ee9 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 18 Oct 2019 15:47:40 -0700 Subject: [PATCH] Fix TestIterate for HashSkipList in db_stress (#5942) Summary: Since SeekForPrev (used by Prev) is not supported by HashSkipList when prefix is used, we disable it when stress testing HashSkipList. - Change the default memtablerep to skip list. - Avoid Prev() when memtablerep is HashSkipList and prefix is used. Test Plan (on devserver): ``` $make db_stress $./db_stress -ops_per_thread=10000 -reopen=1 -destroy_db_initially=true -column_families=1 -threads=1 -column_families=1 -memtablerep=prefix_hash $# or simply $./db_stress $./db_stress -memtablerep=prefix_hash ``` Results must print "Verification successful". Pull Request resolved: https://github.com/facebook/rocksdb/pull/5942 Differential Revision: D18017062 Pulled By: riversand963 fbshipit-source-id: af867e59aa9e6f533143c984d7d529febf232fd7 --- tools/db_stress_tool.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/db_stress_tool.cc b/tools/db_stress_tool.cc index 876de71ed..2b9e063f2 100644 --- a/tools/db_stress_tool.cc +++ b/tools/db_stress_tool.cc @@ -683,7 +683,7 @@ bool GetNextPrefix(const rocksdb::Slice& src, std::string* v) { } // namespace static enum RepFactory FLAGS_rep_factory; -DEFINE_string(memtablerep, "prefix_hash", ""); +DEFINE_string(memtablerep, "skip_list", ""); static bool ValidatePrefixSize(const char* flagname, int32_t value) { if (value < -1 || value > 8) { @@ -2461,8 +2461,11 @@ class StressTest { VerifyIterator(thread, readoptionscopy, iter.get(), cmp_iter.get(), key, &diverged); + bool no_reverse = + (FLAGS_memtablerep == "prefix_hash" && !read_opts.total_order_seek && + options_.prefix_extractor.get() != nullptr); for (uint64_t i = 0; i < FLAGS_num_iterations && iter->Valid(); i++) { - if (thread->rand.OneIn(2)) { + if (no_reverse || thread->rand.OneIn(2)) { iter->Next(); if (!diverged) { assert(cmp_iter->Valid());