Skip to content

Commit e8ed50f

Browse files
authored
[ENH]: add config param to garbage collector to control how many collections are fetched from SysDb (#5275)
1 parent 982b1f1 commit e8ed50f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

rust/garbage_collector/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub struct GarbageCollectorConfig {
4141
)]
4242
pub(super) version_cutoff_time: Duration,
4343
pub(super) max_collections_to_gc: u32,
44+
pub(super) max_collections_to_fetch: Option<u32>,
4445
pub(super) gc_interval_mins: u32,
4546
#[serde(default = "GarbageCollectorConfig::default_min_versions_to_keep")]
4647
pub min_versions_to_keep: u32,

rust/garbage_collector/src/garbage_collector_component.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ impl Handler<GarbageCollectMessage> for GarbageCollector {
363363
.sysdb_client
364364
.get_collections_to_gc(
365365
Some(version_absolute_cutoff_time.into()),
366-
Some(self.config.max_collections_to_gc.into()),
366+
Some(
367+
self.config
368+
.max_collections_to_fetch
369+
.unwrap_or(self.config.max_collections_to_gc)
370+
.into(),
371+
),
367372
message.tenant.clone(),
368373
self.config.filter_min_versions_if_alive,
369374
)
@@ -395,7 +400,9 @@ impl Handler<GarbageCollectMessage> for GarbageCollector {
395400
}
396401

397402
true
398-
}).collect::<Vec<_>>();
403+
})
404+
.take(self.config.max_collections_to_gc as usize)
405+
.collect::<Vec<_>>();
399406

400407
tracing::info!(
401408
"Filtered to {} collections to garbage collect",
@@ -728,6 +735,7 @@ mod tests {
728735
version_cutoff_time: Duration::from_secs(1),
729736
collection_soft_delete_grace_period: Duration::from_secs(1),
730737
max_collections_to_gc: 100,
738+
max_collections_to_fetch: None,
731739
gc_interval_mins: 10,
732740
disallow_collections: HashSet::new(),
733741
min_versions_to_keep: 2,
@@ -865,6 +873,7 @@ mod tests {
865873
version_cutoff_time: Duration::from_secs(1),
866874
collection_soft_delete_grace_period: Duration::from_secs(1),
867875
max_collections_to_gc: 100,
876+
max_collections_to_fetch: None,
868877
min_versions_to_keep: 2,
869878
filter_min_versions_if_alive: None,
870879
gc_interval_mins: 10,

0 commit comments

Comments
 (0)