@@ -623,7 +623,7 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
623623 /// entries is the number of index entries we found were expired, not
624624 /// necessarily the total we deleted or wanted to delete, though they're
625625 /// correlated.
626- pub ( crate ) async fn delete (
626+ async fn delete (
627627 min_snapshot_ts : Timestamp ,
628628 persistence : Arc < dyn Persistence > ,
629629 rt : & RT ,
@@ -690,6 +690,32 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
690690 . map ( |timestamp| ( timestamp, total_expired_entries) )
691691 }
692692
693+ pub async fn delete_all_no_checkpoint (
694+ mut cursor_ts : Timestamp ,
695+ min_snapshot_ts : Timestamp ,
696+ persistence : Arc < dyn Persistence > ,
697+ rt : & RT ,
698+ all_indexes : & BTreeMap < IndexId , ( GenericIndexName < TableId > , IndexedFields ) > ,
699+ retention_validator : Arc < dyn RetentionValidator > ,
700+ ) -> anyhow:: Result < ( ) > {
701+ while cursor_ts. succ ( ) ? < min_snapshot_ts {
702+ let ( new_cursor_ts, _) = Self :: delete (
703+ min_snapshot_ts,
704+ persistence. clone ( ) ,
705+ rt,
706+ cursor_ts,
707+ all_indexes,
708+ retention_validator. clone ( ) ,
709+ )
710+ . await ?;
711+ tracing:: info!(
712+ "custom index retention completed between ts {cursor_ts} and {new_cursor_ts}"
713+ ) ;
714+ cursor_ts = new_cursor_ts;
715+ }
716+ Ok ( ( ) )
717+ }
718+
693719 #[ try_stream( ok = ( Timestamp , InternalDocumentId ) , error = anyhow:: Error ) ]
694720 async fn expired_documents (
695721 rt : & RT ,
@@ -1222,9 +1248,8 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
12221248 Ok ( ( ) )
12231249 }
12241250
1225- async fn get_checkpoint (
1251+ pub async fn get_checkpoint_no_logging (
12261252 persistence : & dyn PersistenceReader ,
1227- snapshot_reader : Reader < SnapshotManager > ,
12281253 retention_type : RetentionType ,
12291254 ) -> anyhow:: Result < Timestamp > {
12301255 let key = match retention_type {
@@ -1239,24 +1264,30 @@ impl<RT: Runtime> LeaderRetentionManager<RT> {
12391264 . map ( ConvexValue :: try_from)
12401265 . transpose ( ) ?;
12411266 let checkpoint = match checkpoint_value {
1242- Some ( ConvexValue :: Int64 ( ts) ) => {
1243- let checkpoint = Timestamp :: try_from ( ts) ?;
1244- match retention_type {
1245- RetentionType :: Document => log_document_retention_cursor_age (
1246- ( * snapshot_reader. lock ( ) . latest_ts ( ) ) . secs_since_f64 ( checkpoint) ,
1247- ) ,
1248- RetentionType :: Index => log_retention_cursor_age (
1249- ( * snapshot_reader. lock ( ) . latest_ts ( ) ) . secs_since_f64 ( checkpoint) ,
1250- ) ,
1251- }
1252- checkpoint
1253- } ,
1267+ Some ( ConvexValue :: Int64 ( ts) ) => Timestamp :: try_from ( ts) ?,
12541268 None => Timestamp :: MIN ,
12551269 _ => anyhow:: bail!( "invalid retention checkpoint {checkpoint_value:?}" ) ,
12561270 } ;
12571271 Ok ( checkpoint)
12581272 }
12591273
1274+ async fn get_checkpoint (
1275+ persistence : & dyn PersistenceReader ,
1276+ snapshot_reader : Reader < SnapshotManager > ,
1277+ retention_type : RetentionType ,
1278+ ) -> anyhow:: Result < Timestamp > {
1279+ let checkpoint = Self :: get_checkpoint_no_logging ( persistence, retention_type) . await ?;
1280+ match retention_type {
1281+ RetentionType :: Document => log_document_retention_cursor_age (
1282+ ( * snapshot_reader. lock ( ) . latest_ts ( ) ) . secs_since_f64 ( checkpoint) ,
1283+ ) ,
1284+ RetentionType :: Index => log_retention_cursor_age (
1285+ ( * snapshot_reader. lock ( ) . latest_ts ( ) ) . secs_since_f64 ( checkpoint) ,
1286+ ) ,
1287+ }
1288+ Ok ( checkpoint)
1289+ }
1290+
12601291 fn accumulate_index_document (
12611292 maybe_doc : Option < ResolvedDocument > ,
12621293 all_indexes : & mut BTreeMap < IndexId , ( GenericIndexName < TableId > , IndexedFields ) > ,
0 commit comments