Don't gossip more snapshot hashes than what we retain (#20379)

This commit is contained in:
Brooks Prumo 2021-10-01 15:59:45 -05:00 committed by GitHub
parent fc5dd7f3bc
commit 4cd50f5d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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());