diff --git a/replica/database.hh b/replica/database.hh index 3e16c29dbd..badf1ba6eb 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -409,9 +409,9 @@ private: compaction_manager& _compaction_manager; sstables::compaction_strategy _compaction_strategy; - // TODO: Still holds a single compaction group, meaning all sstables are eligible to be compacted with one another. Soon, a table - // will be able to hold more than one group. - std::unique_ptr _compaction_group; + std::vector> _compaction_groups; + // FIXME: will be removed once the last ref to single compaction group is gone. + compaction_group* _compaction_group; // Compound SSTable set for all the compaction groups, which is useful for operations spanning all of them. lw_shared_ptr _sstables; // Control background fibers waiting for sstables to be deleted @@ -526,6 +526,7 @@ public: const std::vector& old_sstables); }; private: + std::vector> make_compaction_groups(); // Return compaction group if table owns a single one. Otherwise, null is returned. compaction_group* single_compaction_group_if_available() const noexcept; // Select a compaction group from a given token. diff --git a/replica/table.cc b/replica/table.cc index cef32bdfb8..94fcd1a507 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -472,6 +472,12 @@ void table::enable_off_strategy_trigger() { do_update_off_strategy_trigger(); } +std::vector> table::make_compaction_groups() { + std::vector> ret; + ret.emplace_back(std::make_unique(*this)); + return ret; +} + compaction_group* table::single_compaction_group_if_available() const noexcept { return &*_compaction_group; } @@ -1324,7 +1330,8 @@ table::table(schema_ptr schema, config config, db::commitlog* cl, compaction_man ) , _compaction_manager(compaction_manager) , _compaction_strategy(make_compaction_strategy(_schema->compaction_strategy(), _schema->compaction_strategy_options())) - , _compaction_group(std::make_unique(*this)) + , _compaction_groups(make_compaction_groups()) + , _compaction_group(_compaction_groups.front().get()) , _sstables(make_compound_sstable_set()) , _cache(_schema, sstables_as_snapshot_source(), row_cache_tracker, is_continuous::yes) , _commitlog(cl) diff --git a/scylla-gdb.py b/scylla-gdb.py index 375a4fb390..e23d41a1cc 100755 --- a/scylla-gdb.py +++ b/scylla-gdb.py @@ -4209,9 +4209,13 @@ class scylla_memtables(gdb.Command): for table in all_tables(db): gdb.write('table %s:\n' % schema_ptr(table['_schema']).table_name()) try: - scylla_memtables.dump_compaction_group_memtables(std_unique_ptr(table["_compaction_group"]).get()) + for cg_ptr in std_vector(table["_compaction_groups"]): + scylla_memtables.dump_compaction_group_memtables(std_unique_ptr(cg_ptr).get()) except gdb.error: - scylla_memtables.dump_memtable_list(seastar_lw_shared_ptr(table['_memtables']).get()) # Scylla 5.1 compatibility + try: + scylla_memtables.dump_compaction_group_memtables(std_unique_ptr(table["_compaction_group"]).get()) + except gdb.error: + scylla_memtables.dump_memtable_list(seastar_lw_shared_ptr(table['_memtables']).get()) # Scylla 5.1 compatibility def escape_html(s): return s.replace('&', '&').replace('<', '<').replace('>', '>')