From 34d80690fa87a2545a759136aaa322ea2043707e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 30 Jan 2024 12:14:38 +0800 Subject: [PATCH] replica: table: pass do_flush to table::perform_cleanup_compaction() this parameter defaults to do_flush::yes, so the existing behavior is preserved. and this change prepares for a change which flushes all tables before performing cleanup on the tables per-demand. please note, we cannot pass compaction::flush_mode to this function, as it is used by compaction/task_manager_module.hh, if we want to share it by both database.hh and compaction/task_manager_module.hh, we would have to find it a new home. so `table::do_flush` boolean tag is reused instead. Refs #16757 Signed-off-by: Kefu Chai --- replica/database.hh | 4 +++- replica/table.cc | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/replica/database.hh b/replica/database.hh index 050500b6de..9aecc9052b 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -996,7 +996,9 @@ public: // a future that is resolved when offstrategy_compaction completes. // The future value is true iff offstrategy compaction was required. future perform_offstrategy_compaction(std::optional info = std::nullopt); - future<> perform_cleanup_compaction(owned_ranges_ptr sorted_owned_ranges, std::optional info = std::nullopt); + future<> perform_cleanup_compaction(owned_ranges_ptr sorted_owned_ranges, + std::optional info = std::nullopt, + do_flush = do_flush::yes); unsigned estimate_pending_compactions() const; void set_compaction_strategy(sstables::compaction_strategy_type strategy); diff --git a/replica/table.cc b/replica/table.cc index 97e20204e6..f182b0508e 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -1626,9 +1626,12 @@ future table::perform_offstrategy_compaction(std::optional table::perform_cleanup_compaction(compaction::owned_ranges_ptr sorted_owned_ranges, std::optional info) { - co_await flush(); - +future<> table::perform_cleanup_compaction(compaction::owned_ranges_ptr sorted_owned_ranges, + std::optional info, + do_flush do_flush) { + if (do_flush) { + co_await flush(); + } if (_compaction_groups.size() == 1) { auto& cg = *get_compaction_group(0); co_return co_await get_compaction_manager().perform_cleanup(std::move(sorted_owned_ranges), cg.as_table_state(), info);