From 086ae9cdcd7c9d86244dbd5f7334ca53622c063e Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" <6406592+v0y4g3r@users.noreply.github.com> Date: Wed, 18 Jun 2025 20:04:39 +0800 Subject: [PATCH] chore: print series count after wal replay (#6344) * chore/print-series-count-after-wal-replay: ### Add Series Count Functionality and Logging Enhancements - **`time_partition.rs`**: Introduced `series_count` method to calculate the total timeseries count across all time partitions. - **`opener.rs`**: Enhanced logging to include the total timeseries replayed during WAL replay. - **`version.rs`**: Added `series_count` method to `VersionControlData` for approximating timeseries count in the current version. - **`handler.rs`**: Added entry and exit logging for the `sql` function to trace execution flow. Signed-off-by: Lei, HUANG * chore/print-series-count-after-wal-replay: ### Remove Unused Import - **File Modified**: `src/servers/src/http/handler.rs` - **Change Summary**: Removed the unused `info` import from `common_telemetry`. Signed-off-by: Lei, HUANG --------- Signed-off-by: Lei, HUANG --- src/mito2/src/memtable/time_partition.rs | 12 ++++++++++++ src/mito2/src/region/opener.rs | 5 +++-- src/mito2/src/region/version.rs | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mito2/src/memtable/time_partition.rs b/src/mito2/src/memtable/time_partition.rs index d422daa0b2..fd7e0e1a17 100644 --- a/src/mito2/src/memtable/time_partition.rs +++ b/src/mito2/src/memtable/time_partition.rs @@ -656,6 +656,11 @@ impl TimePartitions { Ok(()) } + + /// Timeseries count in all time partitions. + pub(crate) fn series_count(&self) -> usize { + self.inner.lock().unwrap().series_count() + } } /// Computes the start timestamp of the partition for `ts`. @@ -697,6 +702,13 @@ impl PartitionsInner { self.next_memtable_id += 1; id } + + pub(crate) fn series_count(&self) -> usize { + self.parts + .iter() + .map(|p| p.memtable.stats().series_count) + .sum() + } } /// Time range of a partition. diff --git a/src/mito2/src/region/opener.rs b/src/mito2/src/region/opener.rs index 50e4537550..885963f21e 100644 --- a/src/mito2/src/region/opener.rs +++ b/src/mito2/src/region/opener.rs @@ -665,9 +665,10 @@ where // to avoid reading potentially incomplete entries in the future. (on_region_opened)(region_id, flushed_entry_id, provider).await?; + let series_count = version_control.current().series_count(); info!( - "Replay WAL for region: {}, rows recovered: {}, last entry id: {}", - region_id, rows_replayed, last_entry_id + "Replay WAL for region: {}, rows recovered: {}, last entry id: {}, total timeseries replayed: {}", + region_id, rows_replayed, last_entry_id, series_count ); Ok(last_entry_id) } diff --git a/src/mito2/src/region/version.rs b/src/mito2/src/region/version.rs index c1198e4d16..935b2bdc12 100644 --- a/src/mito2/src/region/version.rs +++ b/src/mito2/src/region/version.rs @@ -249,6 +249,13 @@ pub(crate) struct VersionControlData { pub(crate) is_dropped: bool, } +impl VersionControlData { + /// Approximate timeseries count in current version. + pub(crate) fn series_count(&self) -> usize { + self.version.memtables.mutable.series_count() + } +} + /// Static metadata of a region. #[derive(Clone, Debug)] pub(crate) struct Version {