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,