diff --git a/compaction/compaction_manager.cc b/compaction/compaction_manager.cc index f456433530..6f40c3095e 100644 --- a/compaction/compaction_manager.cc +++ b/compaction/compaction_manager.cc @@ -485,13 +485,8 @@ void compaction_manager::postpone_compaction_for_column_family(column_family* cf _postponed.insert(cf); } -future<> compaction_manager::stop_ongoing_compactions(sstring reason) { - cmlog.info("Stopping {} ongoing compactions due to {}", get_compactions().size(), reason); - - // Wait for each task handler to stop. Copy list because task remove itself - // from the list when done. - auto tasks = _tasks; - return do_with(std::move(tasks), [this, reason] (std::list>& tasks) { +future<> compaction_manager::stop_tasks(std::vector> tasks, sstring reason) { + return do_with(std::move(tasks), [this, reason] (std::vector>& tasks) { return parallel_for_each(tasks, [this, reason] (auto& task) { return this->task_stop(task, reason).then_wrapped([](future <> f) { try { @@ -507,6 +502,15 @@ future<> compaction_manager::stop_ongoing_compactions(sstring reason) { }); } +future<> compaction_manager::stop_ongoing_compactions(sstring reason) { + cmlog.info("Stopping {} ongoing compactions due to {}", get_compactions().size(), reason); + + // Wait for each task handler to stop. Copy list because task remove itself + // from the list when done. + auto tasks = boost::copy_range>>(_tasks); + return stop_tasks(std::move(tasks), std::move(reason)); +} + future<> compaction_manager::drain() { _state = state::disabled; return stop_ongoing_compactions("drain"); diff --git a/compaction/compaction_manager.hh b/compaction/compaction_manager.hh index 0c00abe356..6054a54b64 100644 --- a/compaction/compaction_manager.hh +++ b/compaction/compaction_manager.hh @@ -134,6 +134,7 @@ private: static constexpr std::chrono::seconds periodic_compaction_submission_interval() { return std::chrono::seconds(3600); } private: future<> task_stop(lw_shared_ptr task, sstring reason); + future<> stop_tasks(std::vector> tasks, sstring reason); // Return the largest fan-in of currently running compactions unsigned current_compaction_fan_in_threshold() const;