From 82cf4df3df5763c3edf3781111195ae00c7e50c9 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Tue, 21 Jan 2025 12:22:45 -0800 Subject: [PATCH] storage: always schedule adjacent segment compaction We previously fell back on adjacent segment compaction only if there was no new data to compact. In some situations, we've seen the rate of incoming data outpace the compaction interval, causing segments to pile up without ever being merged. This change tweaks the logic to always run adjacent segment compaction after running sliding window compaction. --- src/v/storage/disk_log_impl.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/v/storage/disk_log_impl.cc b/src/v/storage/disk_log_impl.cc index 91ad021d58d90..44d2d19d2b24f 100644 --- a/src/v/storage/disk_log_impl.cc +++ b/src/v/storage/disk_log_impl.cc @@ -1316,11 +1316,13 @@ ss::future<> disk_log_impl::do_compact( std::rethrow_exception(eptr); } bool compacted = did_compact_fut.get(); - if (!compacted) { - // If sliding window compaction did not occur, we fall back to adjacent - // segment compaction. - co_await compact_adjacent_segments(compact_cfg); - } + vlog( + gclog.debug, + "Sliding compaction of {} did {}compact data, proceeding to adjacent " + "segment compaction", + config().ntp(), + compacted ? "" : "not "); + co_await compact_adjacent_segments(compact_cfg); } ss::future<> disk_log_impl::gc(gc_config cfg) {