From 92056c5cc192f87d86fdde9a29a8a4117cbc0726 Mon Sep 17 00:00:00 2001 From: Alex Chi Z Date: Wed, 29 Jan 2025 20:17:15 +0100 Subject: [PATCH] fix(pageserver): use the larger one of upper limit and threshold Signed-off-by: Alex Chi Z --- pageserver/src/tenant/timeline/compaction.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pageserver/src/tenant/timeline/compaction.rs b/pageserver/src/tenant/timeline/compaction.rs index 589aea18b4007..ea79dc5779e42 100644 --- a/pageserver/src/tenant/timeline/compaction.rs +++ b/pageserver/src/tenant/timeline/compaction.rs @@ -1115,7 +1115,13 @@ impl Timeline { // Under normal circumstances, we will accumulate up to compaction_upper_limit L0s of size // checkpoint_distance each. To avoid edge cases using extra system resources, bound our // work in this function to only operate on this much delta data at once. - let delta_size_limit = self.get_compaction_upper_limit() as u64 + // + // In general, compaction_threshold should be <= compaction_upper_limit, but in case that + // the constraint is not respected, we use the larger of the two. + let delta_size_limit = std::cmp::max( + self.get_compaction_upper_limit(), + self.get_compaction_threshold(), + ) as u64 * std::cmp::max(self.get_checkpoint_distance(), DEFAULT_CHECKPOINT_DISTANCE); let mut fully_compacted = true;