diff --git a/src/meta/src/hummock/compaction/picker/intra_compaction_picker.rs b/src/meta/src/hummock/compaction/picker/intra_compaction_picker.rs index 15cf7e9d01f13..a7cea09ba70f9 100644 --- a/src/meta/src/hummock/compaction/picker/intra_compaction_picker.rs +++ b/src/meta/src/hummock/compaction/picker/intra_compaction_picker.rs @@ -243,6 +243,10 @@ impl IntraCompactionPicker { continue; } + if level_handlers[0].is_level_pending_compact(level) { + continue; + } + if l0.sub_levels[idx + 1].vnode_partition_count != l0.sub_levels[idx].vnode_partition_count { @@ -272,18 +276,6 @@ impl IntraCompactionPicker { assert!(overlap .check_multiple_overlap(&l0.sub_levels[idx].table_infos) .is_empty()); - let mut target_level_idx = idx; - while target_level_idx > 0 { - if l0.sub_levels[target_level_idx - 1].level_type - != LevelType::Nonoverlapping as i32 - || !overlap - .check_multiple_overlap(&l0.sub_levels[target_level_idx - 1].table_infos) - .is_empty() - { - break; - } - target_level_idx -= 1; - } let select_input_size = select_sst.file_size; let input_levels = vec![ @@ -301,7 +293,7 @@ impl IntraCompactionPicker { return Some(CompactionInput { input_levels, target_level: 0, - target_sub_level_id: l0.sub_levels[target_level_idx].sub_level_id, + target_sub_level_id: level.sub_level_id, select_input_size, total_file_count: 1, ..Default::default() diff --git a/src/meta/src/hummock/manager/mod.rs b/src/meta/src/hummock/manager/mod.rs index 8984aff7af042..55676e8139738 100644 --- a/src/meta/src/hummock/manager/mod.rs +++ b/src/meta/src/hummock/manager/mod.rs @@ -1055,11 +1055,10 @@ impl HummockManager { } else { table_to_vnode_partition .retain(|table_id, _| compact_task.existing_table_ids.contains(table_id)); - if group_config.compaction_config.split_weight_by_vnode > 0 { + if compact_task.existing_table_ids.len() == 1 { + table_to_vnode_partition.clear(); for table_id in &compact_task.existing_table_ids { - table_to_vnode_partition - .entry(*table_id) - .or_insert(vnode_partition_count); + table_to_vnode_partition.insert(*table_id, vnode_partition_count); } } diff --git a/src/storage/hummock_sdk/src/compact.rs b/src/storage/hummock_sdk/src/compact.rs index deb0b90bfcd2a..33d895d2c4fcd 100644 --- a/src/storage/hummock_sdk/src/compact.rs +++ b/src/storage/hummock_sdk/src/compact.rs @@ -48,6 +48,12 @@ pub fn compact_task_to_string(compact_task: &CompactTask) -> String { compact_task.existing_table_ids, ) .unwrap(); + writeln!( + s, + "Compaction task partition info: {:?} ", + compact_task.table_vnode_partition, + ) + .unwrap(); s.push_str("Compaction Sstables structure: \n"); for level_entry in &compact_task.input_ssts { let tables: Vec = level_entry @@ -56,12 +62,11 @@ pub fn compact_task_to_string(compact_task: &CompactTask) -> String { .map(|table| { if table.total_key_count != 0 { format!( - "[id: {}, obj_id: {} {}KB stale_ratio {} delete_range_ratio {}]", + "[id: {}, obj_id: {} {}KB stale_ratio {}]", table.get_sst_id(), table.object_id, table.file_size / 1024, (table.stale_key_count * 100 / table.total_key_count), - (table.range_tombstone_count * 100 / table.total_key_count), ) } else { format!( @@ -100,12 +105,9 @@ pub fn append_sstable_info_to_string(s: &mut String, sstable_info: &SstableInfo) let stale_ratio = (sstable_info.stale_key_count * 100) .checked_div(sstable_info.total_key_count) .unwrap_or(0); - let range_tombstone_ratio = (sstable_info.range_tombstone_count * 100) - .checked_div(sstable_info.total_key_count) - .unwrap_or(0); writeln!( s, - "SstableInfo: object id={}, SST id={}, KeyRange=[{:?},{:?}], table_ids: {:?}, size={}KB, stale_ratio={}%, range_tombstone_count={} range_tombstone_ratio={}% bloom_filter_kind {:?}", + "SstableInfo: object id={}, SST id={}, KeyRange=[{:?},{:?}], table_ids: {:?}, size={}KB, stale_ratio={}%, bloom_filter_kind {:?}", sstable_info.get_object_id(), sstable_info.get_sst_id(), left_str, @@ -113,8 +115,6 @@ pub fn append_sstable_info_to_string(s: &mut String, sstable_info: &SstableInfo) sstable_info.table_ids, sstable_info.file_size / 1024, stale_ratio, - sstable_info.range_tombstone_count, - range_tombstone_ratio, sstable_info.bloom_filter_kind, ) .unwrap();