From 5e0d6b4cc9f2f107853ddcff73330f3aa6d17559 Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Tue, 18 Oct 2016 16:07:10 -0700 Subject: [PATCH] fix db_stress assertion failure Summary: in rocksdb::DBIter::FindValueForCurrentKey(), last_not_merge_type could also be SingleDelete() which is omitted Test Plan: db_iter_test Reviewers: yhchiang, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D65187 --- db/db_iter.cc | 3 ++- db/db_iter_test.cc | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/db/db_iter.cc b/db/db_iter.cc index 0c4f2b685..eb89d167f 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -658,7 +658,8 @@ bool DBIter::FindValueForCurrentKey() { return false; case kTypeMerge: current_entry_is_merged_ = true; - if (last_not_merge_type == kTypeDeletion) { + if (last_not_merge_type == kTypeDeletion || + last_not_merge_type == kTypeSingleDeletion) { MergeHelper::TimedFullMerge(merge_operator_, saved_key_.GetKey(), nullptr, merge_context_.GetOperands(), &saved_value_, logger_, statistics_, env_, diff --git a/db/db_iter_test.cc b/db/db_iter_test.cc index c500ab5c5..35da751fd 100644 --- a/db/db_iter_test.cc +++ b/db/db_iter_test.cc @@ -1129,6 +1129,26 @@ TEST_F(DBIteratorTest, DBIterator5) { db_iter->Prev(); ASSERT_TRUE(!db_iter->Valid()); } + + { + // put, singledelete, merge + TestIterator* internal_iter = new TestIterator(BytewiseComparator()); + internal_iter->AddPut("a", "val_a"); + internal_iter->AddSingleDeletion("a"); + internal_iter->AddMerge("a", "merge_1"); + internal_iter->AddMerge("a", "merge_2"); + internal_iter->AddPut("b", "val_b"); + internal_iter->Finish(); + std::unique_ptr db_iter(NewDBIterator( + env_, ImmutableCFOptions(options), BytewiseComparator(), internal_iter, + 10, options.max_sequential_skip_in_iterations, 0)); + db_iter->Seek("b"); + ASSERT_TRUE(db_iter->Valid()); + ASSERT_EQ(db_iter->key().ToString(), "b"); + db_iter->Prev(); + ASSERT_TRUE(db_iter->Valid()); + ASSERT_EQ(db_iter->key().ToString(), "a"); + } } TEST_F(DBIteratorTest, DBIterator6) {