Skip to content

Commit 04e6496

Browse files
authored
chore(cubestore): Reset gauge metrics on shutdown (#7447)
1 parent 129555a commit 04e6496

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

rust/cubestore/cubestore/src/cachestore/cache_rocksstore.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,15 @@ impl RocksCacheStore {
352352
Ok(())
353353
}
354354

355+
fn send_zero_gauge_stats(&self) {
356+
app_metrics::CACHESTORE_ROCKSDB_ESTIMATE_LIVE_DATA_SIZE.report(0);
357+
app_metrics::CACHESTORE_ROCKSDB_LIVE_SST_FILES_SIZE.report(0);
358+
app_metrics::CACHESTORE_ROCKSDB_CF_DEFAULT_SIZE.report(0);
359+
}
360+
355361
pub async fn stop_processing_loops(&self) {
362+
self.send_zero_gauge_stats();
363+
356364
self.cache_eviction_manager.stop_processing_loops();
357365
self.upload_loop.stop();
358366
self.metrics_loop.stop();

rust/cubestore/cubestore/src/cachestore/scheduler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::cachestore::CacheStore;
22
use crate::config::ConfigObj;
33
use crate::metastore::MetaStoreEvent;
44
use crate::shared::deadline_queue::DeadlineQueue;
5-
use crate::CubeError;
5+
use crate::{app_metrics, CubeError};
66
use datafusion::cube_ext;
77
use log::error;
88
use std::sync::Arc;
@@ -130,7 +130,13 @@ impl CacheStoreSchedulerImpl {
130130
}
131131
}
132132

133+
fn send_zero_gauge_stats(&self) {
134+
app_metrics::CACHESTORE_SCHEDULER_GC_QUEUE.report(0);
135+
}
136+
133137
pub fn stop_processing_loops(&self) -> Result<(), CubeError> {
138+
self.send_zero_gauge_stats();
139+
134140
self.cancel_token.cancel();
135141
Ok(())
136142
}

rust/cubestore/cubestore/src/sql/cache.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ impl SqlResultCache {
209209
}
210210
}
211211

212+
impl Drop for SqlResultCache {
213+
fn drop(&mut self) {
214+
app_metrics::DATA_QUERIES_CACHE_SIZE.report(0);
215+
app_metrics::DATA_QUERIES_CACHE_WEIGHT.report(0);
216+
}
217+
}
218+
212219
#[cfg(test)]
213220
mod tests {
214221
use crate::queryplanner::serialized_plan::SerializedPlan;

0 commit comments

Comments
 (0)