From 82f15fb15d9cce7cc0190aba04533afffdcd5f5d Mon Sep 17 00:00:00 2001 From: sdong Date: Tue, 23 Feb 2016 14:54:05 -0800 Subject: [PATCH] Add test to make sure DropColumnFamily doesn't impact existing iterators Summary: Add a test case in ColumnFamilyTest.ReadDroppedColumnFamily to make sure existing iterator is not impacted by column family dropping. Test Plan: N/A Reviewers: igor, yhchiang, anthony, andrewkr, kradhakrishnan, IslamAbdelRahman Reviewed By: IslamAbdelRahman Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D54657 --- db/column_family_test.cc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 1fe7601b1..6e05a7da9 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -1952,13 +1952,27 @@ TEST_F(ColumnFamilyTest, ReadDroppedColumnFamily) { PutRandomData(1, kKeysNum, 100); PutRandomData(2, kKeysNum, 100); - if (iter == 0) { - // Drop CF two - ASSERT_OK(db_->DropColumnFamily(handles_[2])); - } else { - // delete CF two - delete handles_[2]; - handles_[2] = nullptr; + { + std::unique_ptr iterator( + db_->NewIterator(ReadOptions(), handles_[2])); + iterator->SeekToFirst(); + + if (iter == 0) { + // Drop CF two + ASSERT_OK(db_->DropColumnFamily(handles_[2])); + } else { + // delete CF two + delete handles_[2]; + handles_[2] = nullptr; + } + // Make sure iterator created can still be used. + int count = 0; + for (; iterator->Valid(); iterator->Next()) { + ASSERT_OK(iterator->status()); + ++count; + } + ASSERT_OK(iterator->status()); + ASSERT_EQ(count, kKeysNum); } // Add bunch more data to other CFs