compaction_manager: offstrategy compaction: skip compaction if no candidates are found

In many cases we trigger offstrategy compaction opportunistically
also when there's nothing to do.  In this case we still print
to the log lots of info-level message and call
`run_offstrategy_compaction` that wastes more cpu cycles
on learning that it has nothing to do.

This change bails out early if the maintenance set is empty
and prints a "Skipping off-strategy compaction" message in debug
level instead.

Fixes #13466

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2023-04-14 15:26:36 +03:00
parent bd0b299322
commit 1134ca2767

View File

@@ -1264,9 +1264,15 @@ protected:
std::exception_ptr ex;
try {
table_state& t = *_compacting_table;
auto maintenance_sstables = t.maintenance_sstable_set().all();
auto size = t.maintenance_sstable_set().size();
if (!size) {
cmlog.debug("Skipping off-strategy compaction for {}.{}, No candidates were found",
t.schema()->ks_name(), t.schema()->cf_name());
finish_compaction();
co_return std::nullopt;
}
cmlog.info("Starting off-strategy compaction for {}.{}, {} candidates were found",
t.schema()->ks_name(), t.schema()->cf_name(), maintenance_sstables->size());
t.schema()->ks_name(), t.schema()->cf_name(), size);
co_await run_offstrategy_compaction(_compaction_data);
finish_compaction();
cmlog.info("Done with off-strategy compaction for {}.{}", t.schema()->ks_name(), t.schema()->cf_name());