Skip to content

Commit

Permalink
replica: Fix major compaction semantics by performing off-strategy first
Browse files Browse the repository at this point in the history
Major compaction semantics is that all data of a table will be compacted
together, so user can expect e.g. a recently introduced tombstone to be
compacted with the data it shadows.
Today, it can happen that all data in maintenance set won't be included
for major, until they're promoted into main set by off-strategy.
So user might be left wondering why major is not having the expected
effect.
To fix this, let's perform off-strategy first, so data in maintenance
set will be made available by major. A similar approach is done for
data in memtable, so flush is performed before major starts.
The only exception will be data in staging, which cannot be compacted
until view building is done with it, to avoid inconsistency in view
replicas.
The serialization in comapaction manager of reshape jobs guarantee
correctness if there's an ongoing off-strategy on behalf of the
table.

Fixes scylladb#11915.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>

Closes scylladb#15792
  • Loading branch information
raphaelsc authored and denesb committed Oct 23, 2023
1 parent e7dd0ec commit ea6c281
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions replica/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,9 @@ compaction_group::update_main_sstable_list_on_compaction_completion(sstables::co
future<>
table::compact_all_sstables(std::optional<tasks::task_info> info) {
co_await flush();
// Forces off-strategy before major, so sstables previously sitting on maintenance set will be included
// in the compaction's input set, to provide same semantics as before maintenance set came into existence.
co_await perform_offstrategy_compaction(info);
co_await parallel_foreach_compaction_group([this, info] (compaction_group& cg) {
return _compaction_manager.perform_major_compaction(cg.as_table_state(), info);
});
Expand Down

0 comments on commit ea6c281

Please sign in to comment.