From f4a8a1bf22c5225eb26ae3d3fd760c75bda04e6d Mon Sep 17 00:00:00 2001 From: Nikita Sivukhin Date: Sun, 25 Aug 2024 17:12:13 +0400 Subject: [PATCH] bottomless return JoinHandle - so we need to measure upload time inside the handle because function will return almost immediately --- bottomless/src/replicator.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bottomless/src/replicator.rs b/bottomless/src/replicator.rs index 4408958b19..2084f069c3 100644 --- a/bottomless/src/replicator.rs +++ b/bottomless/src/replicator.rs @@ -1087,6 +1087,7 @@ impl Replicator { let snapshot_notifier = self.snapshot_notifier.clone(); let compression = self.use_compression; let db_path = PathBuf::from(self.db_path.clone()); + let db_name = self.db_name.clone(); let handle = tokio::spawn(async move { tracing::trace!("Start snapshotting generation {}", generation); let start = Instant::now(); @@ -1126,13 +1127,13 @@ impl Replicator { let _ = snapshot_notifier.send(Ok(Some(generation))); let elapsed = Instant::now() - start; tracing::debug!("Snapshot upload finished (took {:?})", elapsed); + Self::record_snapshot_upload_time(&db_name, elapsed); // cleanup gzip/zstd database snapshot if exists for suffix in &["gz", "zstd"] { let _ = tokio::fs::remove_file(Self::db_compressed_path(&db_path, suffix)).await; } }); let elapsed = Instant::now() - start_ts; - Self::record_snapshot_upload_time(&self.db_name, elapsed); tracing::debug!("Scheduled DB snapshot {} (took {:?})", generation, elapsed); Ok(Some(handle))