From 5601bc4619402676900539c4ef828cedfa998a32 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 17 Mar 2014 17:02:34 -0700 Subject: [PATCH] Check starts_with(prefix) in MultiPrefixIterate Summary: We switched to prefix_seek method of seeking. This means that anytime we check Valid(), we also need to check starts_with(prefix) Test Plan: ran db_stress Reviewers: ljin Reviewed By: ljin CC: leveldb Differential Revision: https://reviews.facebook.net/D16953 --- tools/db_stress.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/db_stress.cc b/tools/db_stress.cc index a47a03933b..32404c65dc 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -959,13 +959,14 @@ class StressTest { } int count = 0; - while (iters[0]->Valid()) { + while (iters[0]->Valid() && iters[0]->key().starts_with(prefix_slices[0])) { count++; std::string values[10]; // get list of all values for this iteration for (int i = 0; i < 10; i++) { // no iterator should finish before the first one - assert(iters[i]->Valid()); + assert(iters[i]->Valid() && + iters[i]->key().starts_with(prefix_slices[i])); values[i] = iters[i]->value().ToString(); char expected_first = (prefixes[i])[0]; @@ -993,7 +994,8 @@ class StressTest { // cleanup iterators and snapshot for (int i = 0; i < 10; i++) { // if the first iterator finished, they should have all finished - assert(!iters[i]->Valid()); + assert(!iters[i]->Valid() || + !iters[i]->key().starts_with(prefix_slices[i])); assert(iters[i]->status().ok()); delete iters[i]; }