From 4cd50f5d45ca425ead8fc87a26882a17fd403e30 Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Fri, 1 Oct 2021 15:59:45 -0500 Subject: [PATCH] Don't gossip more snapshot hashes than what we retain (#20379) --- core/src/snapshot_packager_service.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/snapshot_packager_service.rs b/core/src/snapshot_packager_service.rs index 821b735ce..003cc100e 100644 --- a/core/src/snapshot_packager_service.rs +++ b/core/src/snapshot_packager_service.rs @@ -29,6 +29,10 @@ impl SnapshotPackagerService { ) -> Self { let exit = exit.clone(); let cluster_info = cluster_info.clone(); + let max_snapshot_hashes = std::cmp::min( + MAX_SNAPSHOT_HASHES, + snapshot_config.maximum_full_snapshot_archives_to_retain, + ); let t_snapshot_packager = Builder::new() .name("snapshot-packager".to_string()) @@ -64,7 +68,7 @@ impl SnapshotPackagerService { // can have their hashes pushed out to the cluster. if snapshot_package.snapshot_type == SnapshotType::FullSnapshot { hashes.push((snapshot_package.slot(), *snapshot_package.hash())); - while hashes.len() > MAX_SNAPSHOT_HASHES { + while hashes.len() > max_snapshot_hashes { hashes.remove(0); } cluster_info.push_snapshot_hashes(hashes.clone());