From e3f02c7fb9f558067a760fd90437a7cc1091f9ef Mon Sep 17 00:00:00 2001 From: Li0k Date: Tue, 10 Sep 2024 02:38:38 +0800 Subject: [PATCH] typo --- .../compaction/compaction_group_schedule.rs | 1 + .../hummock_test/src/compactor_tests.rs | 92 ++++++------------- 2 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/meta/src/hummock/manager/compaction/compaction_group_schedule.rs b/src/meta/src/hummock/manager/compaction/compaction_group_schedule.rs index 2ad2811273132..92af3f69bbfcc 100644 --- a/src/meta/src/hummock/manager/compaction/compaction_group_schedule.rs +++ b/src/meta/src/hummock/manager/compaction/compaction_group_schedule.rs @@ -152,6 +152,7 @@ impl HummockManager { let left_obj_id = left_last_sst.object_id; let right_obj_id = right_first_sst.object_id; + // Since the sst key_range within a group is legal, we only need to check the ssts adjacent to the two groups. if !can_concat(&[left_last_sst, right_first_sst]) { return Err(Error::CompactionGroup(format!( "invalid merge group_1 {} group_2 {} level_idx {} left_last_sst_id {} right_first_sst_id {} left_obj_id {} right_obj_id {}", diff --git a/src/storage/hummock_test/src/compactor_tests.rs b/src/storage/hummock_test/src/compactor_tests.rs index 7c8048c61caee..92856fb5022c6 100644 --- a/src/storage/hummock_test/src/compactor_tests.rs +++ b/src/storage/hummock_test/src/compactor_tests.rs @@ -2128,19 +2128,31 @@ pub(crate) mod tests { let parent_group_id = 2; let split_table_ids = vec![table_id_2.table_id()]; - // compact - { + async fn compact_once( + group_id: CompactionGroupId, + level: usize, + hummock_manager_ref: HummockManagerRef, + compact_ctx: CompactorContext, + filter_key_extractor_manager: FilterKeyExtractorManager, + sstable_object_id_manager: Arc, + ) { + // compact left group let manual_compcation_option = ManualCompactionOption { - level: 0, + level, ..Default::default() }; // 2. get compact task - let mut compact_task = hummock_manager_ref - .manual_get_compact_task(parent_group_id, manual_compcation_option) + let compact_task = hummock_manager_ref + .manual_get_compact_task(group_id, manual_compcation_option) .await - .unwrap() .unwrap(); + if compact_task.is_none() { + return; + } + + let mut compact_task = compact_task.unwrap(); + let compaction_filter_flag = CompactionFilterFlag::STATE_CLEAN | CompactionFilterFlag::TTL; compact_task.compaction_filter_mask = compaction_filter_flag.bits(); @@ -2152,7 +2164,7 @@ pub(crate) mod tests { // 3. compact let (_tx, rx) = tokio::sync::oneshot::channel(); let ((result_task, task_stats), _) = compact( - compact_ctx.clone(), + compact_ctx, compact_task.clone(), rx, Box::new(sstable_object_id_manager.clone()), @@ -2171,6 +2183,17 @@ pub(crate) mod tests { .unwrap(); } + // compact + compact_once( + parent_group_id, + 0, + hummock_manager_ref.clone(), + compact_ctx.clone(), + filter_key_extractor_manager.clone(), + sstable_object_id_manager.clone(), + ) + .await; + let new_cg_id = hummock_manager_ref .split_compaction_group(parent_group_id, &split_table_ids, 0) .await @@ -2197,61 +2220,6 @@ pub(crate) mod tests { .await; epoch += millisec_interval_epoch; - async fn compact_once( - group_id: CompactionGroupId, - level: usize, - hummock_manager_ref: HummockManagerRef, - compact_ctx: CompactorContext, - filter_key_extractor_manager: FilterKeyExtractorManager, - sstable_object_id_manager: Arc, - ) { - // compact left group - let manual_compcation_option = ManualCompactionOption { - level, - ..Default::default() - }; - // 2. get compact task - let compact_task = hummock_manager_ref - .manual_get_compact_task(group_id, manual_compcation_option) - .await - .unwrap(); - - if compact_task.is_none() { - return; - } - - let mut compact_task = compact_task.unwrap(); - - let compaction_filter_flag = - CompactionFilterFlag::STATE_CLEAN | CompactionFilterFlag::TTL; - compact_task.compaction_filter_mask = compaction_filter_flag.bits(); - compact_task.current_epoch_time = hummock_manager_ref - .get_current_version() - .await - .max_committed_epoch(); - - // 3. compact - let (_tx, rx) = tokio::sync::oneshot::channel(); - let ((result_task, task_stats), _) = compact( - compact_ctx, - compact_task.clone(), - rx, - Box::new(sstable_object_id_manager.clone()), - filter_key_extractor_manager.clone(), - ) - .await; - - hummock_manager_ref - .report_compact_task( - result_task.task_id, - result_task.task_status, - result_task.sorted_output_ssts, - Some(to_prost_table_stats_map(task_stats)), - ) - .await - .unwrap(); - } - compact_once( parent_group_id, 0,