Skip to content

Commit 5548e01

Browse files
goffrieConvex, Inc.
authored andcommitted
Add progress info to LeaderRetentionManager::delete_all_no_checkpoint (#42576)
GitOrigin-RevId: f30801c6f5bc38380f3451268917f32ad2b3e452
1 parent 545a3c4 commit 5548e01

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/database/src/retention.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use std::{
1212
Hasher,
1313
},
1414
sync::Arc,
15-
time::Duration,
15+
time::{
16+
Duration,
17+
Instant,
18+
},
1619
};
1720

1821
use anyhow::Context;
@@ -723,6 +726,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
723726
all_indexes: &BTreeMap<IndexId, (GenericIndexName<TabletId>, IndexedFields)>,
724727
retention_validator: Arc<dyn RetentionValidator>,
725728
) -> anyhow::Result<()> {
729+
let mut last_logged = Instant::now();
726730
while cursor_ts.succ()? < *min_snapshot_ts {
727731
let (new_cursor_ts, _) = Self::delete(
728732
min_snapshot_ts,
@@ -732,10 +736,16 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
732736
retention_validator.clone(),
733737
)
734738
.await?;
739+
let now = Instant::now();
740+
let duration = now.saturating_duration_since(last_logged).as_secs_f64();
741+
let catchup_rate = new_cursor_ts.secs_since_f64(*cursor_ts) / duration;
742+
let lag = min_snapshot_ts.secs_since_f64(*new_cursor_ts);
735743
tracing::info!(
736-
"custom index retention completed between ts {cursor_ts} and {new_cursor_ts}"
744+
"custom index retention completed between ts {cursor_ts} and {new_cursor_ts}; \
745+
catchup rate: {catchup_rate:.1}s/s, {lag:.1}s behind snapshot"
737746
);
738747
cursor_ts = new_cursor_ts;
748+
last_logged = now;
739749
}
740750
Ok(())
741751
}

0 commit comments

Comments
 (0)