Skip to content

Commit

Permalink
fix(compaction): support trivial reclaim (#10457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Little-Wallace authored Jun 21, 2023
1 parent b50d0e9 commit cd69fd7
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 267 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions proto/hummock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ message IntraLevelDelta {
repeated SstableInfo inserted_table_infos = 4;
}

enum CompatibilityVersion {
VERSION_UNSPECIFIED = 0;
NO_TRIVIAL_SPLIT = 1;
}

message GroupConstruct {
CompactionConfig group_config = 1;
// If `parent_group_id` is not 0, it means `parent_group_id` splits into `parent_group_id` and this group, so this group is not empty initially.
uint64 parent_group_id = 2;
repeated uint32 table_ids = 3;
uint64 group_id = 4;
uint64 new_sst_start_id = 5;
CompatibilityVersion version = 6;
}

message GroupMetaChange {
Expand All @@ -76,6 +82,7 @@ message GroupTableChange {
uint64 target_group_id = 2;
uint64 origin_group_id = 3;
uint64 new_sst_start_id = 4;
CompatibilityVersion version = 5;
}

message GroupDestroy {}
Expand Down
1 change: 1 addition & 0 deletions src/meta/src/hummock/compaction/level_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ impl LevelSelector for SpaceReclaimCompactionSelector {
.state
.entry(group.group_id)
.or_insert_with(SpaceReclaimPickerState::default);

let compaction_input = picker.pick_compaction(levels, level_handlers, state)?;
compaction_input.add_pending_task(task_id, level_handlers);

Expand Down
11 changes: 11 additions & 0 deletions src/meta/src/hummock/compaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ impl CompactStatus {
false
}

pub fn is_trivial_reclaim(task: &CompactTask) -> bool {
let exist_table_ids = HashSet::<u32>::from_iter(task.existing_table_ids.clone());
task.input_ssts.iter().all(|level| {
level.table_infos.iter().all(|sst| {
sst.table_ids
.iter()
.all(|table_id| !exist_table_ids.contains(table_id))
})
})
}

/// Declares a task as either succeeded, failed or canceled.
pub fn report_compact_task(&mut self, compact_task: &CompactTask) {
for level in &compact_task.input_ssts {
Expand Down
Loading

0 comments on commit cd69fd7

Please sign in to comment.