diff --git a/db/compaction/compaction_picker.cc b/db/compaction/compaction_picker.cc index 758cc626f..42d7f8b2c 100644 --- a/db/compaction/compaction_picker.cc +++ b/db/compaction/compaction_picker.cc @@ -554,10 +554,14 @@ void CompactionPicker::GetGrandparents( InternalKey start, limit; GetRange(inputs, output_level_inputs, &start, &limit); // Compute the set of grandparent files that overlap this compaction - // (parent == level+1; grandparent == level+2) - if (output_level_inputs.level + 1 < NumberLevels()) { - vstorage->GetOverlappingInputs(output_level_inputs.level + 1, &start, - &limit, grandparents); + // (parent == level+1; grandparent == level+2 or the first + // level after that has overlapping files) + for (int level = output_level_inputs.level + 1; level < NumberLevels(); + level++) { + vstorage->GetOverlappingInputs(level, &start, &limit, grandparents); + if (!grandparents->empty()) { + break; + } } }