Skip to content

Commit e4b9d72

Browse files
authored
Merge pull request #28996 from dotnwat/manual-backport-28935-v25.3.x-95
[v25.3.x] Manual backport of #28935 and #28947
2 parents 5d3ac9b + 497c3c6 commit e4b9d72

File tree

7 files changed

+59
-24
lines changed

7 files changed

+59
-24
lines changed

src/v/cloud_topics/level_zero/gc/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ redpanda_cc_library(
3636
"//src/v/cloud_io:io_result",
3737
"//src/v/cloud_storage_clients",
3838
"//src/v/cloud_topics:types",
39+
"//src/v/config",
3940
"//src/v/container:chunked_hash_map",
4041
"//src/v/model",
4142
"@seastar",

src/v/cloud_topics/level_zero/gc/level_zero_gc.cc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ level_zero_gc::level_zero_gc(
324324
level_zero_gc_config config,
325325
std::unique_ptr<object_storage> storage,
326326
std::unique_ptr<epoch_source> epoch_source)
327-
: config_(config)
327+
: config_(std::move(config))
328328
, storage_(std::move(storage))
329329
, epoch_source_(std::move(epoch_source))
330330
, should_run_(false) // begin in a stopped state
@@ -337,10 +337,18 @@ level_zero_gc::level_zero_gc(
337337
cloud_storage_clients::bucket_name bucket,
338338
seastar::sharded<cluster::health_monitor_frontend>* health_monitor,
339339
seastar::sharded<cluster::controller_stm>* controller_stm,
340-
seastar::sharded<cluster::topic_table>* topic_table,
341-
level_zero_gc_config config)
340+
seastar::sharded<cluster::topic_table>* topic_table)
342341
: level_zero_gc(
343-
config,
342+
level_zero_gc_config{
343+
.deletion_grace_period
344+
= config::shard_local_cfg()
345+
.cloud_topics_short_term_gc_minimum_object_age.bind(),
346+
.throttle_progress
347+
= config::shard_local_cfg().cloud_topics_short_term_gc_interval.bind(),
348+
.throttle_no_progress
349+
= config::shard_local_cfg()
350+
.cloud_topics_short_term_gc_backoff_interval.bind(),
351+
},
344352
std::make_unique<object_storage_remote_impl>(remote, std::move(bucket)),
345353
std::make_unique<epoch_source_impl>(
346354
health_monitor, controller_stm, topic_table)) {}
@@ -402,16 +410,16 @@ seastar::future<> level_zero_gc::worker() {
402410
auto res = co_await try_to_collect();
403411
if (res.has_value()) {
404412
if (res.value() > 0) {
405-
backoff = config_.throttle_progress;
413+
backoff = config_.throttle_progress();
406414
} else {
407-
backoff = config_.throttle_no_progress;
415+
backoff = config_.throttle_no_progress();
408416
}
409417
} else {
410418
switch (res.error()) {
411419
case collection_error::service_error:
412420
case collection_error::invalid_object_name:
413421
case collection_error::no_collectible_epoch:
414-
backoff = config_.throttle_no_progress;
422+
backoff = config_.throttle_no_progress();
415423
}
416424
}
417425

@@ -420,7 +428,7 @@ seastar::future<> level_zero_gc::worker() {
420428
cd_log.info,
421429
"Level zero GC restarting after error: {}",
422430
std::current_exception());
423-
backoff = config_.throttle_no_progress;
431+
backoff = config_.throttle_no_progress();
424432
}
425433
}
426434

@@ -455,7 +463,7 @@ level_zero_gc::try_to_collect() {
455463
}
456464

457465
const auto max_gc_birthday = std::chrono::system_clock::now()
458-
- config_.deletion_grace_period;
466+
- config_.deletion_grace_period();
459467

460468
vlog(
461469
cd_log.debug,

src/v/cloud_topics/level_zero/gc/level_zero_gc.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "cloud_storage_clients/client.h"
1414
#include "cloud_topics/level_zero/gc/level_zero_gc_probe.h"
1515
#include "cloud_topics/types.h"
16+
#include "config/property.h"
1617
#include "container/chunked_hash_map.h"
1718

1819
#include <seastar/core/condition-variable.hh>
@@ -136,16 +137,9 @@ namespace cloud_topics {
136137
* epochs starting at 0.
137138
*/
138139
struct level_zero_gc_config {
139-
/*
140-
* TODO(noah): the grace period controls the minimum age of objects before
141-
* they are eligible for removal, and likely deserves to be a proper
142-
* configuration tunable. The throttling parameters are for preventing the
143-
* polling worker from spinning. The throttling policy is very crude, and
144-
* will need to be revisited, but should keep things in check for now.
145-
*/
146-
std::chrono::milliseconds deletion_grace_period{10s};
147-
std::chrono::milliseconds throttle_progress{2s};
148-
std::chrono::milliseconds throttle_no_progress{10s};
140+
config::binding<std::chrono::milliseconds> deletion_grace_period;
141+
config::binding<std::chrono::milliseconds> throttle_progress;
142+
config::binding<std::chrono::milliseconds> throttle_no_progress;
149143
};
150144

151145
class level_zero_gc {
@@ -249,8 +243,7 @@ class level_zero_gc {
249243
cloud_storage_clients::bucket_name,
250244
seastar::sharded<cluster::health_monitor_frontend>*,
251245
seastar::sharded<cluster::controller_stm>*,
252-
seastar::sharded<cluster::topic_table>*,
253-
level_zero_gc_config = {});
246+
seastar::sharded<cluster::topic_table>*);
254247

255248
/*
256249
* Request that GC be started or paused. These can be called multiple times

src/v/cloud_topics/level_zero/gc/tests/level_zero_gc_tests.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ class LevelZeroGCTest : public testing::Test {
110110
LevelZeroGCTest()
111111
: gc(
112112
cloud_topics::level_zero_gc_config{
113-
.deletion_grace_period = 12h,
114-
.throttle_progress = 10ms,
115-
.throttle_no_progress = 10ms,
113+
.deletion_grace_period
114+
= config::mock_binding<std::chrono::milliseconds>(12h),
115+
.throttle_progress
116+
= config::mock_binding<std::chrono::milliseconds>(10ms),
117+
.throttle_no_progress
118+
= config::mock_binding<std::chrono::milliseconds>(10ms),
116119
},
117120
std::make_unique<object_storage_test_impl>(&listed, &deleted),
118121
std::make_unique<epoch_source_test_impl>(&max_epoch)) {}

src/v/config/configuration.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4576,6 +4576,27 @@ configuration::configuration()
45764576
"The local cache duration of a cluster wide epoch.",
45774577
{.needs_restart = needs_restart::no, .visibility = visibility::tunable},
45784578
1min)
4579+
, cloud_topics_short_term_gc_minimum_object_age(
4580+
*this,
4581+
"cloud_topics_short_term_gc_minimum_object_age",
4582+
"The minimum age of an L0 object before it becomes eligible for garbage "
4583+
"collection.",
4584+
{.needs_restart = needs_restart::no, .visibility = visibility::tunable},
4585+
12h)
4586+
, cloud_topics_short_term_gc_interval(
4587+
*this,
4588+
"cloud_topics_short_term_gc_interval",
4589+
"The interval between invocations of the L0 garbage collection work loop "
4590+
"when progress is being made.",
4591+
{.needs_restart = needs_restart::no, .visibility = visibility::tunable},
4592+
10s)
4593+
, cloud_topics_short_term_gc_backoff_interval(
4594+
*this,
4595+
"cloud_topics_short_term_gc_backoff_interval",
4596+
"The interval between invocations of the L0 garbage collection work loop "
4597+
"when no progress is being made or errors are occurring.",
4598+
{.needs_restart = needs_restart::no, .visibility = visibility::tunable},
4599+
1min)
45794600
, development_feature_property_testing_only(
45804601
*this,
45814602
"development_feature_property_testing_only",

src/v/config/configuration.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,12 @@ struct configuration final : public config_store {
823823
property<std::chrono::milliseconds>
824824
cloud_topics_epoch_service_local_epoch_cache_duration;
825825

826+
property<std::chrono::milliseconds>
827+
cloud_topics_short_term_gc_minimum_object_age;
828+
property<std::chrono::milliseconds> cloud_topics_short_term_gc_interval;
829+
property<std::chrono::milliseconds>
830+
cloud_topics_short_term_gc_backoff_interval;
831+
826832
development_feature_property<int> development_feature_property_testing_only;
827833

828834
private:

tests/rptest/tests/cloud_topics/l0_gc_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def __init__(self, test_context: TestContext):
3838
"cloud_topics_reconciliation_interval": 2000,
3939
"cloud_topics_epoch_service_epoch_increment_interval": 5000,
4040
"cloud_topics_epoch_service_local_epoch_cache_duration": 5000,
41+
"cloud_topics_short_term_gc_minimum_object_age": 10000,
42+
"cloud_topics_short_term_gc_interval": 2000,
43+
"cloud_topics_short_term_gc_backoff_interval": 10000,
4144
}
4245
super(CloudTopicsL0GCTest, self).__init__(
4346
test_context=test_context,

0 commit comments

Comments
 (0)