diff --git a/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs b/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs index 548d2201bd46c..ed375041aad46 100644 --- a/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs +++ b/src/meta/src/hummock/compaction/picker/base_level_compaction_picker.rs @@ -134,11 +134,6 @@ impl LevelCompactionPicker { level_handlers: &[LevelHandler], stats: &mut LocalPickerStatistic, ) -> Option { - if l0.sub_levels.len() < 1 || l0.sub_levels[0].vnode_partition_count < vnode_partition_count - { - return None; - } - let overlap_strategy = create_overlap_strategy(self.config.compaction_mode()); let min_compaction_bytes = self.config.sub_level_max_compaction_bytes; let non_overlap_sub_level_picker = NonOverlapSubLevelPicker::new( diff --git a/src/meta/src/hummock/compaction/selector/level_selector.rs b/src/meta/src/hummock/compaction/selector/level_selector.rs index a43cdbf5e15fa..ae8379ad1ec9c 100644 --- a/src/meta/src/hummock/compaction/selector/level_selector.rs +++ b/src/meta/src/hummock/compaction/selector/level_selector.rs @@ -224,7 +224,18 @@ impl DynamicLevelSelectorCore { // range at each level, so the number of levels is the most important factor affecting // the read performance. At the same time, the size factor is also added to the score // calculation rule to avoid unbalanced compact task due to large size. - let total_size = levels.l0.as_ref().unwrap().total_file_size + let total_size = levels + .l0 + .as_ref() + .unwrap() + .sub_levels + .iter() + .filter(|level| { + level.vnode_partition_count == levels.vnode_partition_count + && level.level_type() == LevelType::Nonoverlapping + }) + .map(|level| level.total_file_size) + .sum::() - handlers[0].get_pending_output_file_size(ctx.base_level as u32); let base_level_size = levels.get_level(ctx.base_level).total_file_size; let base_level_sst_count = levels.get_level(ctx.base_level).table_infos.len() as u64;