diff --git a/replica/table.cc b/replica/table.cc index 55b5484efe..643141a0ff 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -987,7 +987,7 @@ future<> table::compact_sstables(sstables::compaction_descriptor descriptor, sstables::compaction_data& cdata) { if (!descriptor.sstables.size()) { // if there is nothing to compact, just return. - return make_ready_future<>(); + co_return; } descriptor.creator = [this] (shard_id dummy) { @@ -1005,23 +1005,22 @@ table::compact_sstables(sstables::compaction_descriptor descriptor, sstables::co auto compaction_type = descriptor.options.type(); auto start_size = boost::accumulate(descriptor.sstables | boost::adaptors::transformed(std::mem_fn(&sstables::sstable::data_size)), uint64_t(0)); - return sstables::compact_sstables(std::move(descriptor), cdata, as_table_state()).then([this, &cdata, compaction_type, start_size] (sstables::compaction_result res) { - if (compaction_type != sstables::compaction_type::Compaction) { - return make_ready_future<>(); - } - // skip update if running without a query context, for example, when running a test case. - if (!db::qctx) { - return make_ready_future<>(); - } - auto ended_at = std::chrono::duration_cast(res.ended_at.time_since_epoch()).count(); + sstables::compaction_result res = co_await sstables::compact_sstables(std::move(descriptor), cdata, as_table_state()); + if (compaction_type != sstables::compaction_type::Compaction) { + co_return; + } + // skip update if running without a query context, for example, when running a test case. + if (!db::qctx) { + co_return; + } + auto ended_at = std::chrono::duration_cast(res.ended_at.time_since_epoch()).count(); - // FIXME: add support to merged_rows. merged_rows is a histogram that - // shows how many sstables each row is merged from. This information - // cannot be accessed until we make combined_reader more generic, - // for example, by adding a reducer method. - return db::system_keyspace::update_compaction_history(cdata.compaction_uuid, _schema->ks_name(), _schema->cf_name(), ended_at, - start_size, res.end_size, std::unordered_map{}); - }); + // FIXME: add support to merged_rows. merged_rows is a histogram that + // shows how many sstables each row is merged from. This information + // cannot be accessed until we make combined_reader more generic, + // for example, by adding a reducer method. + co_return co_await db::system_keyspace::update_compaction_history(cdata.compaction_uuid, _schema->ks_name(), _schema->cf_name(), ended_at, + start_size, res.end_size, std::unordered_map{}); } future<>