From d58d64919eceeba6b6a5efae2df4f29fe662fa5a Mon Sep 17 00:00:00 2001 From: Willem Kaufmann Date: Fri, 17 May 2024 11:15:49 -0400 Subject: [PATCH] rptest: fix retention value in `archive_retention_test` The `retention_value` for `retention.bytes` in `archive_retention_test.test_delete` was being set to a value of `1KiB` by default. Sometimes, a segment smaller than `1KiB` would be produced, and thus would not be garbage collected. The `retention_value` is now set using the minimum segment size to ensure all segments are properly deleted per the expectations of the test. (cherry picked from commit 7c8738e3d6e424b17b3bafc6291ea4b9cb07315a) --- tests/rptest/tests/archive_retention_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/rptest/tests/archive_retention_test.py b/tests/rptest/tests/archive_retention_test.py index 7562a47209a6..9873532d69ab 100644 --- a/tests/rptest/tests/archive_retention_test.py +++ b/tests/rptest/tests/archive_retention_test.py @@ -182,13 +182,13 @@ def new_manifest_spilled(): # will be deleted (in case of retention.ms) time.sleep(2) - retention_value = 1000 # 1KiB or 1s - self.logger.debug(f"Setting {retention_type} to {retention_value}") - for part_id in range(0, topic.partition_count): ntp = NTP(ns='kafka', topic=topic.name, partition=part_id) summaries = view.segment_summaries(ntp) if retention_type == 'retention.bytes': + retention_value = max( + min(summaries, key=lambda s: s.size_bytes).size_bytes - 1, + 0) segments_to_delete = len(summaries) else: retention_value = 1000 # 1s @@ -198,6 +198,8 @@ def new_manifest_spilled(): if s.base_timestamp < (current_time - retention_value) ]) + self.logger.debug(f"Setting {retention_type} to {retention_value}") + # Note: altering the topic config will re-init the archiver and # reset the metric tracking segment deletion. This is why we assign # to `segments_to_delete` instead of adding.