diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 56d1889aa1..649615c016 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -1248,7 +1248,7 @@ pub fn purge_old_snapshot_archives

( P: AsRef, { info!( - "Purging old snapshot archives in {}, retaining {} full snapshots and {} incremental snapshots", + "Purging old snapshot archives in {}, retaining up to {} full snapshots and up to {} incremental snapshots", snapshot_archives_dir.as_ref().display(), maximum_full_snapshot_archives_to_retain, maximum_incremental_snapshot_archives_to_retain @@ -1257,6 +1257,12 @@ pub fn purge_old_snapshot_archives

( snapshot_archives.sort_unstable(); snapshot_archives.reverse(); let max_snaps = max(1, maximum_full_snapshot_archives_to_retain); // Always keep at least one snapshot + trace!( + "There are {} full snapshot archives, purging {} of them", + snapshot_archives.len(), + snapshot_archives.len().saturating_sub(max_snaps) + ); + for old_archive in snapshot_archives.into_iter().skip(max_snaps) { trace!( "Purging old full snapshot archive: {}", @@ -1296,8 +1302,20 @@ pub fn purge_old_snapshot_archives

( } }); - incremental_snapshot_archives_with_same_base_slot.sort_unstable(); + if !incremental_snapshot_archives_with_different_base_slot.is_empty() { + trace!( + "Purging {} incremental snapshot archives with a different base slot than the highest full snapshot slot", + incremental_snapshot_archives_with_different_base_slot.len() + ); + } + trace!( + "There are {} incremental snapshots with same base slot as the highest full snapshot slot, purging {} of them", + incremental_snapshot_archives_with_same_base_slot.len(), + incremental_snapshot_archives_with_same_base_slot.len() + .saturating_sub(maximum_incremental_snapshot_archives_to_retain) + ); + incremental_snapshot_archives_with_same_base_slot.sort_unstable(); incremental_snapshot_archives_with_different_base_slot .iter() .chain(