Skip to content

Commit

Permalink
chore(storage): add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Sep 9, 2024
1 parent e755671 commit ffd9728
Show file tree
Hide file tree
Showing 4 changed files with 492 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,44 @@ impl HummockManager {
.collect_vec();
assert!(combined_member_table_ids.is_sorted());

// check duplicated sst_id
let mut sst_id_set = HashSet::new();
for sst in versioning.current_version.get_sst_ids() {
if !sst_id_set.insert(sst) {
return Err(Error::CompactionGroup(format!(
"invalid merge group_1 {} group_2 {} duplicated sst_id {}",
left_group_id, right_group_id, sst
)));
}
}

// TODO(li0k): remove this check (Since the current split_sst does not change key_range, this check can not be removed, otherwise concate will fail.)
// check branched sst on non-overlap level
{
for level in versioning
.current_version
.get_compaction_group_levels(group_1)
.levels
.iter()
.chain(
versioning
.current_version
.get_compaction_group_levels(group_2)
.levels
.iter(),
)
{
for sst in &level.table_infos {
if sst.sst_id != sst.object_id {
return Err(Error::CompactionGroup(format!(
"invalid merge group_1 {} group_2 {} branched sst_id {}",
left_group_id, right_group_id, sst.sst_id
)));
}
}
}
}

let mut version = HummockVersionTransaction::new(
&mut versioning.current_version,
&mut versioning.hummock_version_deltas,
Expand Down
8 changes: 6 additions & 2 deletions src/storage/hummock_sdk/src/compaction_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ pub mod group_split {
can_concat(&left_levels.levels[idx].table_infos),
"{}",
format!(
"left_levels.levels[{}].table_infos: {:?} level_idx {:?}",
idx, left_levels.levels[idx].table_infos, left_levels.levels[idx].level_idx
"left-group {} right-group {} left_levels.levels[{}].table_infos: {:?} level_idx {:?}",
left_levels.group_id,
right_levels.group_id,
idx,
left_levels.levels[idx].table_infos,
left_levels.levels[idx].level_idx
)
);
}
Expand Down
Loading

0 comments on commit ffd9728

Please sign in to comment.