VersionSet::AddLiveFiles() to assert current version is included.

Summary: Add an extra assert to make sure current version is included in VersionSet::AddLiveFiles().

Test Plan: make all check

Reviewers: yhchiang, rven, igor

Reviewed By: igor

Subscribers: dhruba, hermanlee4, leveldb

Differential Revision: https://reviews.facebook.net/D30819
This commit is contained in:
sdong 2015-01-07 10:43:29 -08:00
parent 4d16a9a633
commit 9ef59a09a5

View File

@ -2636,15 +2636,20 @@ void VersionSet::AddLiveFiles(std::vector<FileDescriptor>* live_list) {
live_list->reserve(live_list->size() + static_cast<size_t>(total_files)); live_list->reserve(live_list->size() + static_cast<size_t>(total_files));
for (auto cfd : *column_family_set_) { for (auto cfd : *column_family_set_) {
auto* current = cfd->current();
bool found_current = false;
Version* dummy_versions = cfd->dummy_versions(); Version* dummy_versions = cfd->dummy_versions();
for (Version* v = dummy_versions->next_; v != dummy_versions; for (Version* v = dummy_versions->next_; v != dummy_versions;
v = v->next_) { v = v->next_) {
const auto* vstorage = v->storage_info(); v->AddLiveFiles(live_list);
for (int level = 0; level < vstorage->num_levels(); level++) { if (v == current) {
for (const auto& f : vstorage->LevelFiles(level)) { found_current = true;
live_list->push_back(f->fd);
} }
} }
if (!found_current && current != nullptr) {
// Should never happen unless it is a bug.
assert(false);
current->AddLiveFiles(live_list);
} }
} }
} }