diff --git a/compaction/compaction_manager.cc b/compaction/compaction_manager.cc index 2f576aa96d..4108a25915 100644 --- a/compaction/compaction_manager.cc +++ b/compaction/compaction_manager.cc @@ -1097,7 +1097,12 @@ private: compaction::table_state& t = *_compacting_table; const auto& maintenance_sstables = t.maintenance_sstable_set(); - const auto old_sstables = boost::copy_range>(*maintenance_sstables.all()); + // Filter out sstables that require view building, to avoid a race between off-strategy + // and view building. Refs: #11882 + const auto old_sstables = boost::copy_range>(*maintenance_sstables.all() + | boost::adaptors::filtered([] (const sstables::shared_sstable& sst) { + return !sst->requires_view_building(); + })); std::vector reshape_candidates = old_sstables; std::vector sstables_to_remove; std::unordered_set new_unused_sstables; diff --git a/replica/table.cc b/replica/table.cc index b49a856f25..b7f248117b 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -2380,6 +2380,11 @@ future<> table::move_sstables_from_staging(std::vector co_await coroutine::parallel_for_each(dirs_to_sync, [] (sstring dir) { return sync_directory(dir); }); + // Off-strategy timer will be rearmed, so if there's more incoming data through repair / streaming, + // the timer can be updated once again. In practice, it allows off-strategy compaction to kick off + // at the end of the node operation on behalf of this table, which brings more efficiency in terms + // of write amplification. + do_update_off_strategy_trigger(); } /**