Fix reduce levels

ReduceNumberOfLevels had segmentation fault in WriteSnapshot() since we
didn't change the number of levels in VersionSet (we consider them
immutable from now on). This fixes the problem.
This commit is contained in:
Igor Canadi 2014-01-24 18:30:00 -08:00
parent 8477255da3
commit 04afa32134

View File

@ -1779,8 +1779,11 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
} }
std::vector<FileMetaData*>* old_files_list = current_version->files_; std::vector<FileMetaData*>* old_files_list = current_version->files_;
// we need to allocate an array with the old number of levels size to
// avoid SIGSEGV in WriteSnapshot()
// however, all levels bigger or equal to new_levels will be empty
std::vector<FileMetaData*>* new_files_list = std::vector<FileMetaData*>* new_files_list =
new std::vector<FileMetaData*>[new_levels]; new std::vector<FileMetaData*>[current_levels];
for (int i = 0; i < new_levels - 1; i++) { for (int i = 0; i < new_levels - 1; i++) {
new_files_list[i] = old_files_list[i]; new_files_list[i] = old_files_list[i];
} }