From 2f293fa09c7e7f1736b97733a0204587253fd01a Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Thu, 4 Nov 2021 12:52:09 -0300 Subject: [PATCH] compaction_manager: prevent compaction from being postponed when stopping tasks stop_tasks() must make sure that no ongoing task will postpone compaction when asked to stop. Therefore, let's set all tasks as stopping before any deferring point, such that no task will postpone compaction for a table which is being stopped. compaction_manager::remove() already handles this race with the same method, and given that remove() will later switch to stop_tasks(), let's do the same in stop_tasks(). Signed-off-by: Raphael S. Carvalho --- compaction/compaction_manager.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compaction/compaction_manager.cc b/compaction/compaction_manager.cc index 6f40c3095e..2aac9951c1 100644 --- a/compaction/compaction_manager.cc +++ b/compaction/compaction_manager.cc @@ -486,6 +486,11 @@ void compaction_manager::postpone_compaction_for_column_family(column_family* cf } future<> compaction_manager::stop_tasks(std::vector> tasks, sstring reason) { + // To prevent compaction from being postponed while tasks are being stopped, let's set all + // tasks as stopping before the deferring point below. + for (auto& t : tasks) { + t->stopping = true; + } 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) {