From dad98dd4ae2a9dccec5297c104a9885c3912264e Mon Sep 17 00:00:00 2001 From: Venkatesh Radhakrishnan Date: Tue, 3 Feb 2015 12:19:56 -0800 Subject: [PATCH] Changes for supporting cross functional tests for inplace_update Summary: This diff containes the changes to the code and db_test for supporting cross functional tests for inplace_update Test Plan: Run XF with inplace_test and also without Reviewers: igor, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D32367 --- db/db_test.cc | 10 +++++++--- db/memtable.h | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 735ed30f2..5ae209ad6 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2432,8 +2432,10 @@ TEST(DBTest, IterPrevMaxSkip) { } TEST(DBTest, IterWithSnapshot) { + anon::OptionsOverride options_override; + options_override.skip_policy = kSkipNoSnapshot; do { - CreateAndReopenWithCF({"pikachu"}, CurrentOptions()); + CreateAndReopenWithCF({"pikachu"}, CurrentOptions(options_override)); ASSERT_OK(Put(1, "key1", "val1")); ASSERT_OK(Put(1, "key2", "val2")); ASSERT_OK(Put(1, "key3", "val3")); @@ -8098,9 +8100,11 @@ static bool CompareIterators(int step, } TEST(DBTest, Randomized) { + anon::OptionsOverride options_override; + options_override.skip_policy = kSkipNoSnapshot; Random rnd(test::RandomSeed()); do { - ModelDB model(CurrentOptions()); + ModelDB model(CurrentOptions(options_override)); const int N = 10000; const Snapshot* model_snap = nullptr; const Snapshot* db_snap = nullptr; @@ -8170,7 +8174,7 @@ TEST(DBTest, Randomized) { if (db_snap != nullptr) db_->ReleaseSnapshot(db_snap); - auto options = CurrentOptions(); + auto options = CurrentOptions(options_override); Reopen(options); ASSERT_TRUE(CompareIterators(step, &model, db_, nullptr, nullptr)); diff --git a/db/memtable.h b/db/memtable.h index 0c1f0de1a..f3befce7d 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -196,7 +196,10 @@ class MemTable { } // return true if the current MemTableRep supports snapshots. - bool IsSnapshotSupported() const { return table_->IsSnapshotSupported(); } + // inplace update prevents snapshots, + bool IsSnapshotSupported() const { + return table_->IsSnapshotSupported() && !moptions_.inplace_update_support; + } // Get the lock associated for the key port::RWMutex* GetLock(const Slice& key);