From 1244abef663b63ebaf15660c50a67c1f6fd77951 Mon Sep 17 00:00:00 2001 From: sdong Date: Wed, 8 Jan 2020 13:30:51 -0800 Subject: [PATCH] Stress Test: relax prefix iterator check condition (#6269) Summary: Right now, when validating prefix iterator, if control iterator is invalidate but prefix iterator shows value, we determine it as a test failure. However, this fails to consider the case where a file or memtable containing a tombstone is filtered out by a prefix bloom filter. The fix is to relax the check in this case. If we are out of prefix range, then ignore the check. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6269 Test Plan: Run crash_test for a short while and it still passes. Differential Revision: D19317594 fbshipit-source-id: b964a1cdc1df5efe439d4b32f8023e1fbc8598c1 --- db_stress_tool/db_stress_test_base.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index c059c2a5e..dd9f00c87 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -1040,7 +1040,26 @@ void StressTest::VerifyIterator(ThreadState* thread, return; } + const SliceTransform* pe = + ro.total_order_seek ? nullptr : options_.prefix_extractor.get(); + const Comparator* cmp = options_.comparator; + if (iter->Valid() && !cmp_iter->Valid()) { + if (pe != nullptr) { + if (!pe->InDomain(seek_key)) { + // Prefix seek a non-in-domain key is undefined. Skip checking for + // this scenario. + *diverged = true; + return; + } else if (!pe->InDomain(iter->key())) { + // out of range is iterator key is not in domain anymore. + *diverged = true; + return; + } else if (pe->Transform(iter->key()) != pe->Transform(seek_key)) { + *diverged = true; + return; + } + } fprintf(stderr, "Control interator is invalid but iterator has key %s " "%s\n", @@ -1051,9 +1070,6 @@ void StressTest::VerifyIterator(ThreadState* thread, // 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 = - ro.total_order_seek ? nullptr : options_.prefix_extractor.get(); - const Comparator* cmp = options_.comparator; if (pe != nullptr) { if (!pe->InDomain(seek_key)) {