Skip to content

Commit

Permalink
compaction_manager: compact_sstables: retrieve owned ranges if required
Browse files Browse the repository at this point in the history
If any of the sstables to-be-compacted requires cleanup,
retrive the owned_ranges_ptr from the table_state.

With that, staging sstables will eventually be cleaned up
via regular compaction.

\Refs scylladb#9559

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
(cherry picked from commit 4db961e)
  • Loading branch information
bhalevy committed Aug 31, 2023
1 parent 9c6f3f9 commit fed771b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions compaction/compaction_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,24 @@ future<sstables::compaction_result> compaction_manager::task::compact_sstables(s
on_replace.on_removal(old_sstables);
};

// retrieve owned_ranges if_required
if (!descriptor.owned_ranges) {
std::vector<sstables::shared_sstable> sstables_requiring_cleanup;
const auto& cs = _cm.get_compaction_state(_compacting_table);
for (const auto& sst : descriptor.sstables) {
if (cs.sstables_requiring_cleanup.contains(sst)) {
sstables_requiring_cleanup.emplace_back(sst);
}
}
if (!sstables_requiring_cleanup.empty()) {
cmlog.info("The following SSTables require cleaned up in this compaction: {}", sstables_requiring_cleanup);
if (!cs.owned_ranges_ptr) {
on_internal_error_noexcept(cmlog, "SSTables require cleanup but compaction state has null owned ranges");
}
descriptor.owned_ranges = cs.owned_ranges_ptr;
}
}

co_return co_await sstables::compact_sstables(std::move(descriptor), cdata, t);
}
future<> compaction_manager::task::update_history(compaction::table_state& t, const sstables::compaction_result& res, const sstables::compaction_data& cdata) {
Expand Down

0 comments on commit fed771b

Please sign in to comment.