Skip to content

Commit

Permalink
fix(compaction): fix compatible for vnode partition (#14489)
Browse files Browse the repository at this point in the history
Signed-off-by: Little-Wallace <[email protected]>
  • Loading branch information
Little-Wallace committed Jan 20, 2024
1 parent 549dd3d commit c4d98f6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
1 change: 0 additions & 1 deletion proto/hummock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ message HummockVersion {
uint64 group_id = 3;
uint64 parent_group_id = 4;
repeated uint32 member_table_ids = 5;
uint32 vnode_partition_count = 6;
}
uint64 id = 1;
// Levels of each compaction group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ impl CompactionPicker for LevelCompactionPicker {
level_handlers,
stats,
) {
ret.vnode_partition_count = levels.vnode_partition_count;
ret.vnode_partition_count = self.config.split_weight_by_vnode;
return Some(ret);
}

debug_assert!(self.target_level == levels.get_level(self.target_level).level_idx as usize);
if let Some(ret) = self.pick_multi_level_to_base(
l0,
levels.get_level(self.target_level),
levels.vnode_partition_count,
self.config.split_weight_by_vnode,
level_handlers,
stats,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl CompactionPicker for IntraCompactionPicker {
return None;
}

let vnode_partition_count = levels.vnode_partition_count;
let vnode_partition_count = self.config.split_weight_by_vnode;

if let Some(ret) =
self.pick_whole_level(l0, &level_handlers[0], vnode_partition_count, stats)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct MinOverlappingPicker {
level: usize,
target_level: usize,
max_select_bytes: u64,
vnode_partition_count: u32,
overlap_strategy: Arc<dyn OverlapStrategy>,
}

Expand All @@ -36,12 +37,14 @@ impl MinOverlappingPicker {
level: usize,
target_level: usize,
max_select_bytes: u64,
vnode_partition_count: u32,
overlap_strategy: Arc<dyn OverlapStrategy>,
) -> MinOverlappingPicker {
MinOverlappingPicker {
level,
target_level,
max_select_bytes,
vnode_partition_count,
overlap_strategy,
}
}
Expand Down Expand Up @@ -163,7 +166,7 @@ impl CompactionPicker for MinOverlappingPicker {
},
],
target_level: self.target_level,
vnode_partition_count: levels.vnode_partition_count,
vnode_partition_count: self.vnode_partition_count,
..Default::default()
})
}
Expand Down Expand Up @@ -425,7 +428,7 @@ pub mod tests {
#[test]
fn test_compact_l1() {
let mut picker =
MinOverlappingPicker::new(1, 2, 10000, Arc::new(RangeOverlapStrategy::default()));
MinOverlappingPicker::new(1, 2, 10000, 0, Arc::new(RangeOverlapStrategy::default()));
let levels = vec![
Level {
level_idx: 1,
Expand Down Expand Up @@ -497,7 +500,7 @@ pub mod tests {
#[test]
fn test_expand_l1_files() {
let mut picker =
MinOverlappingPicker::new(1, 2, 10000, Arc::new(RangeOverlapStrategy::default()));
MinOverlappingPicker::new(1, 2, 10000, 0, Arc::new(RangeOverlapStrategy::default()));
let levels = vec![
Level {
level_idx: 1,
Expand Down Expand Up @@ -822,7 +825,7 @@ pub mod tests {
];
// no limit
let picker =
MinOverlappingPicker::new(2, 3, 1000, Arc::new(RangeOverlapStrategy::default()));
MinOverlappingPicker::new(2, 3, 1000, 0, Arc::new(RangeOverlapStrategy::default()));
let (select_files, target_files) = picker.pick_tables(
&levels[1].table_infos,
&levels[2].table_infos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ impl CompactionPicker for TierCompactionPicker {
return None;
}

self.pick_overlapping_level(l0, &level_handlers[0], levels.vnode_partition_count, stats)
self.pick_overlapping_level(
l0,
&level_handlers[0],
self.config.split_weight_by_vnode,
stats,
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/meta/src/hummock/compaction/selector/level_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl DynamicLevelSelectorCore {
picker_info.select_level,
picker_info.target_level,
self.config.max_bytes_for_level_base / 2,
self.config.split_weight_by_vnode,
overlap_strategy,
))
}
Expand Down Expand Up @@ -245,7 +246,7 @@ impl DynamicLevelSelectorCore {
.sub_levels
.iter()
.filter(|level| {
level.vnode_partition_count == levels.vnode_partition_count
level.vnode_partition_count == self.config.split_weight_by_vnode
&& level.level_type() == LevelType::Nonoverlapping
})
.map(|level| level.total_file_size)
Expand Down
6 changes: 1 addition & 5 deletions src/meta/src/hummock/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,7 @@ impl HummockManager {
} else {
table_to_vnode_partition
.retain(|table_id, _| compact_task.existing_table_ids.contains(table_id));
if current_version
.get_compaction_group_levels(compaction_group_id)
.vnode_partition_count
> 0
{
if group_config.compaction_config.split_weight_by_vnode > 0 {
for table_id in &compact_task.existing_table_ids {
table_to_vnode_partition
.entry(*table_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,6 @@ pub fn build_initial_compaction_group_levels(
group_id,
parent_group_id: StaticCompactionGroupId::NewCompactionGroup as _,
member_table_ids: vec![],
vnode_partition_count: compaction_config.split_weight_by_vnode,
}
}

Expand Down

0 comments on commit c4d98f6

Please sign in to comment.