diff --git a/HISTORY.md b/HISTORY.md index 034676b268..dbae316f5c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,7 @@ ### New Features * Support Multiple DB paths in universal style compactions * Add feature of storing plain table index and bloom filter in SST file. +* CompactRange() will never output compacted files to level 0. This used to be the case when all the compaction input files were at level 0. ### Public API changes * DBOptions.db_paths now is a vector of a DBPath structure which indicates both of path and target size diff --git a/db/db_impl.cc b/db/db_impl.cc index 986fda3e30..09ea62ef92 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1638,10 +1638,12 @@ Status DBImpl::CompactRange(ColumnFamilyHandle* column_family, } for (int level = 0; level <= max_level_with_files; level++) { // in case the compaction is unversal or if we're compacting the - // bottom-most level, the output level will be the same as input one + // bottom-most level, the output level will be the same as input one. + // level 0 can never be the bottommost level (i.e. if all files are in level + // 0, we will compact to level 1) if (cfd->options()->compaction_style == kCompactionStyleUniversal || cfd->options()->compaction_style == kCompactionStyleFIFO || - level == max_level_with_files) { + (level == max_level_with_files && level > 0)) { s = RunManualCompaction(cfd, level, level, target_path_id, begin, end); } else { s = RunManualCompaction(cfd, level, level + 1, target_path_id, begin,