From b0cc058ba2d9003efac19a8e27651b63833a611a 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 cee5b3dbe08e..94a8518dd1c0 100644 --- a/src/mito2/src/cache/file_cache.rs +++ b/src/mito2/src/cache/file_cache.rs @@ -213,7 +213,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 e8afdd041bdf..bbb12b4c6483 100644 --- a/src/mito2/src/cache/write_cache.rs +++ b/src/mito2/src/cache/write_cache.rs @@ -101,6 +101,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 @@ -122,11 +127,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,