From 6fb1f3c53ae9db66ce6016fa40f8f23b1665b79c Mon Sep 17 00:00:00 2001 From: QuenKar <47681251+QuenKar@users.noreply.github.com> Date: Tue, 9 Jan 2024 14:22:11 +0800 Subject: [PATCH] chore: cr comment --- src/mito2/src/cache/file_cache.rs | 2 +- src/mito2/src/cache/write_cache.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mito2/src/cache/file_cache.rs b/src/mito2/src/cache/file_cache.rs index e50cd327018f..99f44a723100 100644 --- a/src/mito2/src/cache/file_cache.rs +++ b/src/mito2/src/cache/file_cache.rs @@ -200,7 +200,7 @@ pub(crate) type IndexKey = (RegionId, FileId); #[derive(Debug, Clone)] pub(crate) struct IndexValue { /// Size of the file in bytes. - pub file_size: u32, + pub(crate) file_size: u32, } /// Generates the path to the cached file. diff --git a/src/mito2/src/cache/write_cache.rs b/src/mito2/src/cache/write_cache.rs index 8a73f642be83..baba6b68dbb3 100644 --- a/src/mito2/src/cache/write_cache.rs +++ b/src/mito2/src/cache/write_cache.rs @@ -90,6 +90,11 @@ impl WriteCache { timer.stop_and_record(); // Upload sst file to remote object store. + if sst_info.is_none() { + // No data need to upload. + return Ok(None); + } + let timer = FLUSH_ELAPSED.with_label_values(&["upload"]).start_timer(); let reader = self @@ -111,11 +116,11 @@ impl WriteCache { .await .context(error::UploadSstSnafu { region_id, file_id })?; - UPLOAD_BYTES_TOTAL.inc_by(bytes_written); - // Must close to upload all data. writer.close().await.context(error::OpenDalSnafu)?; + UPLOAD_BYTES_TOTAL.inc_by(bytes_written); + debug!( "Successfully upload file to remote, region: {}, file: {}, upload_path: {}, cost: {:?}s", region_id,