From f267f4684ea089162a8622988a8a8bfe30bcebd7 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Wed, 25 Nov 2026 08:12:52 +0000 Subject: [PATCH] fix(mito2): count published shared SST output toward region write load Signed-off-by: WenyXu --- src/mito2/src/engine/table_compaction/tests.rs | 13 +++++++++++++ src/mito2/src/worker/handle_manifest.rs | 14 +++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/mito2/src/engine/table_compaction/tests.rs b/src/mito2/src/engine/table_compaction/tests.rs index b280c0ed518..fab96e0ac42 100644 --- a/src/mito2/src/engine/table_compaction/tests.rs +++ b/src/mito2/src/engine/table_compaction/tests.rs @@ -332,6 +332,15 @@ async fn test_partial_success_can_retry_both_regions_without_duplicate_files() { let b = RegionId::new(1, 2); let (snapshot_a, output_a) = seed(&engine, a).await; let (snapshot_b, output_b) = seed(&engine, b).await; + let bytes = |id| { + engine + .get_region(id) + .unwrap() + .region_statistic() + .ingested_parquet_bytes + }; + let before_a = bytes(a); + let before_b = bytes(b); let invalid = FileMeta { file_size: output_b.file_size + 1, ..output_b.clone() @@ -342,6 +351,8 @@ async fn test_partial_success_can_retry_both_regions_without_duplicate_files() { ); assert_eq!(PublicationOutcome::Applied, first_a.unwrap()); assert!(first_b.is_err()); + assert_eq!(bytes(a), before_a + output_a.file_size); + assert_eq!(bytes(b), before_b); assert_eq!( snapshot_b.inputs, engine.table_compaction_snapshot(b).unwrap().inputs @@ -352,6 +363,8 @@ async fn test_partial_success_can_retry_both_regions_without_duplicate_files() { ); assert_eq!(PublicationOutcome::Applied, retry_a.unwrap()); assert_eq!(PublicationOutcome::Applied, retry_b.unwrap()); + assert_eq!(bytes(a), before_a + output_a.file_size); + assert_eq!(bytes(b), before_b + output_b.file_size); for (id, output) in [(a, output_a), (b, output_b)] { let region = engine.get_region(id).unwrap(); let manifest = region.manifest_ctx.manifest().await; diff --git a/src/mito2/src/worker/handle_manifest.rs b/src/mito2/src/worker/handle_manifest.rs index b7d68c7a4b2..e20890cdadb 100644 --- a/src/mito2/src/worker/handle_manifest.rs +++ b/src/mito2/src/worker/handle_manifest.rs @@ -468,8 +468,8 @@ impl RegionWorkerLoop { return RegionEditDispatch::Rejected; } - let ingested_parquet_bytes = if matches!(kind, RegionEditKind::Ingest) { - match new_ingested_parquet_bytes(®ion, &edit) { + let ingested_parquet_bytes = match &kind { + RegionEditKind::Ingest => match new_ingested_parquet_bytes(®ion, &edit) { Ok(bytes) => bytes, Err(error) => { let error = Arc::new(error); @@ -477,9 +477,13 @@ impl RegionWorkerLoop { .reply_with(|| Err(error.clone()).context(EditRegionSnafu { region_id })); return RegionEditDispatch::Rejected; } - } - } else { - 0 + }, + #[cfg(feature = "enterprise")] + RegionEditKind::Compaction(_) => edit + .files_to_add + .iter() + .fold(0u64, |bytes, file| bytes.saturating_add(file.file_size)), + RegionEditKind::Import => 0, }; // Allow retrieving `is_staging` before spawn the edit region task.