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
This commit is contained in:
sdong 2016-02-23 14:54:05 -08:00
parent 38201b3599
commit 82f15fb15d

View File

@ -1952,13 +1952,27 @@ TEST_F(ColumnFamilyTest, ReadDroppedColumnFamily) {
PutRandomData(1, kKeysNum, 100); PutRandomData(1, kKeysNum, 100);
PutRandomData(2, kKeysNum, 100); PutRandomData(2, kKeysNum, 100);
if (iter == 0) { {
// Drop CF two std::unique_ptr<Iterator> iterator(
ASSERT_OK(db_->DropColumnFamily(handles_[2])); db_->NewIterator(ReadOptions(), handles_[2]));
} else { iterator->SeekToFirst();
// delete CF two
delete handles_[2]; if (iter == 0) {
handles_[2] = nullptr; // 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 // Add bunch more data to other CFs