From 2cdaf5ca5b3803d38529d983742a61342934564f Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 1 Oct 2021 17:21:39 -0700 Subject: [PATCH] Add additional checks for three existing unit tests (#8973) Summary: With test sync points, we can assert on the equality of iterator value in three existing unit tests. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8973 Test Plan: ``` gtest-parallel -r 1000 ./db_test2 --gtest_filter=DBTest2.IterRaceFlush2:DBTest2.IterRaceFlush1:DBTest2.IterRefreshRaceFlush ``` make check Reviewed By: akankshamahajan15 Differential Revision: D31256340 Pulled By: riversand963 fbshipit-source-id: a9440767ab383e0ec61bd43ffa8fbec4ba562ea2 --- db/db_test2.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/db/db_test2.cc b/db/db_test2.cc index e4f22ce60..7d10ec673 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -3670,14 +3670,15 @@ TEST_F(DBTest2, IterRaceFlush1) { TEST_SYNC_POINT("DBTest2::IterRaceFlush:2"); }); - // iterator is created after the first Put(), so it should see either - // "v1" or "v2". + // iterator is created after the first Put(), and its snapshot sequence is + // assigned after second Put(), so it must see v2. { std::unique_ptr it(db_->NewIterator(ReadOptions())); it->Seek("foo"); ASSERT_TRUE(it->Valid()); ASSERT_OK(it->status()); ASSERT_EQ("foo", it->key().ToString()); + ASSERT_EQ("v2", it->value().ToString()); } t1.join(); @@ -3700,14 +3701,15 @@ TEST_F(DBTest2, IterRaceFlush2) { TEST_SYNC_POINT("DBTest2::IterRaceFlush2:2"); }); - // iterator is created after the first Put(), so it should see either - // "v1" or "v2". + // iterator is created after the first Put(), and its snapshot sequence is + // assigned before second Put(), thus it must see v1. { std::unique_ptr it(db_->NewIterator(ReadOptions())); it->Seek("foo"); ASSERT_TRUE(it->Valid()); ASSERT_OK(it->status()); ASSERT_EQ("foo", it->key().ToString()); + ASSERT_EQ("v1", it->value().ToString()); } t1.join(); @@ -3730,8 +3732,8 @@ TEST_F(DBTest2, IterRefreshRaceFlush) { TEST_SYNC_POINT("DBTest2::IterRefreshRaceFlush:2"); }); - // iterator is created after the first Put(), so it should see either - // "v1" or "v2". + // iterator is refreshed after the first Put(), and its sequence number is + // assigned after second Put(), thus it must see v2. { std::unique_ptr it(db_->NewIterator(ReadOptions())); ASSERT_OK(it->status()); @@ -3740,6 +3742,7 @@ TEST_F(DBTest2, IterRefreshRaceFlush) { ASSERT_TRUE(it->Valid()); ASSERT_OK(it->status()); ASSERT_EQ("foo", it->key().ToString()); + ASSERT_EQ("v2", it->value().ToString()); } t1.join();