diff --git a/compaction/compaction_manager.cc b/compaction/compaction_manager.cc index ce4ce34e49..67e68a10b1 100644 --- a/compaction/compaction_manager.cc +++ b/compaction/compaction_manager.cc @@ -2050,6 +2050,10 @@ void compaction_manager::add(table_state& t) { future<> compaction_manager::remove(table_state& t) noexcept { auto& c_state = get_compaction_state(&t); + auto erase_state = defer([&t, &c_state, this] () noexcept { + c_state.backlog_tracker->disable(); + _compaction_state.erase(&t); + }); // We need to guarantee that a task being stopped will not retry to compact // a table being removed. @@ -2064,10 +2068,6 @@ future<> compaction_manager::remove(table_state& t) noexcept { co_await std::move(close_gate); } - c_state.backlog_tracker->disable(); - - _compaction_state.erase(&t); - #ifdef DEBUG auto found = false; sstring msg;