table: add perform_cleanup_compaction

Move the integration with compaction_manager
from the api layer to the tabel class so
it can also make sure the memtable is cleaned up in the next patch.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2022-11-06 12:37:35 +02:00
parent 85523c45c0
commit fc278be6c4
3 changed files with 12 additions and 2 deletions

View File

@@ -660,7 +660,7 @@ void set_storage_service(http_context& ctx, routes& r, sharded<service::storage_
// as a table can be dropped during loop below, let's find it before issuing the cleanup request.
for (auto& id : table_ids) {
replica::table& t = db.find_column_family(id);
co_await cm.perform_cleanup(owned_ranges_ptr, t.as_table_state());
co_await t.perform_cleanup_compaction(owned_ranges_ptr);
}
co_return;
}).then([]{

View File

@@ -900,6 +900,8 @@ public:
// a future<bool> that is resolved when offstrategy_compaction completes.
// The future value is true iff offstrategy compaction was required.
future<bool> perform_offstrategy_compaction();
future<> perform_cleanup_compaction(owned_ranges_ptr sorted_owned_ranges);
void set_compaction_strategy(sstables::compaction_strategy_type strategy);
const sstables::compaction_strategy& get_compaction_strategy() const {
return _compaction_strategy;
@@ -909,7 +911,11 @@ public:
return _compaction_strategy;
}
const compaction_manager& get_compaction_manager() const {
const compaction_manager& get_compaction_manager() const noexcept {
return _compaction_manager;
}
compaction_manager& get_compaction_manager() noexcept {
return _compaction_manager;
}

View File

@@ -1149,6 +1149,10 @@ future<bool> table::perform_offstrategy_compaction() {
return _compaction_manager.perform_offstrategy(as_table_state());
}
future<> table::perform_cleanup_compaction(compaction::owned_ranges_ptr sorted_owned_ranges) {
co_await get_compaction_manager().perform_cleanup(std::move(sorted_owned_ranges), as_table_state());
}
void table::set_compaction_strategy(sstables::compaction_strategy_type strategy) {
tlogger.debug("Setting compaction strategy of {}.{} to {}", _schema->ks_name(), _schema->cf_name(), sstables::compaction_strategy::name(strategy));
auto new_cs = make_compaction_strategy(strategy, _schema->compaction_strategy_options());