From 9ef59a09a50c61e4743fc7edac6a660853cbd9fd Mon Sep 17 00:00:00 2001 From: sdong Date: Wed, 7 Jan 2015 10:43:29 -0800 Subject: [PATCH] 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 --- db/version_set.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/db/version_set.cc b/db/version_set.cc index 0dbac7667..b206fe5b3 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2636,16 +2636,21 @@ void VersionSet::AddLiveFiles(std::vector* live_list) { live_list->reserve(live_list->size() + static_cast(total_files)); for (auto cfd : *column_family_set_) { + auto* current = cfd->current(); + bool found_current = false; Version* dummy_versions = cfd->dummy_versions(); for (Version* v = dummy_versions->next_; v != dummy_versions; v = v->next_) { - const auto* vstorage = v->storage_info(); - for (int level = 0; level < vstorage->num_levels(); level++) { - for (const auto& f : vstorage->LevelFiles(level)) { - live_list->push_back(f->fd); - } + v->AddLiveFiles(live_list); + if (v == current) { + found_current = true; } } + if (!found_current && current != nullptr) { + // Should never happen unless it is a bug. + assert(false); + current->AddLiveFiles(live_list); + } } }