Skip to content

Commit

Permalink
storage: always schedule adjacent segment compaction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrwng committed Jan 21, 2025
1 parent 3e03d8e commit 82cf4df
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/v/storage/disk_log_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 82cf4df

Please sign in to comment.