From 352cda4467320abe07d3cc449ab849e87ac873ff Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 19 Aug 2025 23:27:55 +0300 Subject: [PATCH] treewide: avoid including gms/feature_service.hh from headers To avoid dependency proliferation, switch to forward declarations. In one case, we introduce indirection via std::unique_ptr and deinline the constructor and destructor. Ref #1 Closes scylladb/scylladb#25584 --- index/secondary_index_manager.hh | 7 ++++++- service/topology_coordinator.hh | 2 +- tools/read_mutation.cc | 10 ++++++++++ tools/read_mutation.hh | 12 ++++-------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/index/secondary_index_manager.hh b/index/secondary_index_manager.hh index 7b72313fbc..79b0f81972 100644 --- a/index/secondary_index_manager.hh +++ b/index/secondary_index_manager.hh @@ -10,7 +10,6 @@ #pragma once -#include "gms/feature_service.hh" #include "schema/schema.hh" #include "data_dictionary/data_dictionary.hh" @@ -26,6 +25,12 @@ enum class oper_t; } +namespace gms { + +class feature_service; + +} + namespace secondary_index { sstring index_table_name(const sstring& index_name); diff --git a/service/topology_coordinator.hh b/service/topology_coordinator.hh index ca2fc768eb..168d925168 100644 --- a/service/topology_coordinator.hh +++ b/service/topology_coordinator.hh @@ -15,7 +15,6 @@ #include "utils/log.hh" #include "raft/raft.hh" -#include "gms/feature_service.hh" #include "service/endpoint_lifecycle_subscriber.hh" #include "service/topology_state_machine.hh" @@ -26,6 +25,7 @@ class system_distributed_keyspace; namespace gms { class gossiper; +class feature_service; } namespace netw { diff --git a/tools/read_mutation.cc b/tools/read_mutation.cc index 8348c6568d..19fd342446 100644 --- a/tools/read_mutation.cc +++ b/tools/read_mutation.cc @@ -10,10 +10,20 @@ #include "readers/combined.hh" #include "replica/database.hh" #include "partition_slice_builder.hh" +#include "gms/feature_service.hh" #include #include +sstable_manager_service::sstable_manager_service(const db::config& dbcfg, sstable_compressor_factory& scf) + : corrupt_data_handler(db::corrupt_data_handler::register_metrics::no) + , feature_service_impl(std::make_unique(gms::feature_config{get_disabled_features_from_db_config(dbcfg)})) + , dir_sem(1) + , sst_man("schema_loader", large_data_handler, corrupt_data_handler, dbcfg, feature_service, tracker, memory::stats().total_memory(), dir_sem, []{ return locator::host_id{}; }, scf, abort) { +} + +sstable_manager_service::~sstable_manager_service() = default; + future get_table_directory(std::filesystem::path scylla_data_path, std::string_view keyspace_name, std::string_view table_name) { diff --git a/tools/read_mutation.hh b/tools/read_mutation.hh index b2f95476f8..8e97d174ec 100644 --- a/tools/read_mutation.hh +++ b/tools/read_mutation.hh @@ -18,7 +18,6 @@ #include "db/config.hh" #include "db/large_data_handler.hh" #include "db/corrupt_data_handler.hh" -#include "gms/feature_service.hh" #include "schema/schema_fwd.hh" #include "sstables/sstable_directory.hh" #include "sstables/sstables_manager.hh" @@ -32,18 +31,15 @@ future get_table_directory(std::filesystem::path scylla_d struct sstable_manager_service { db::nop_large_data_handler large_data_handler; db::nop_corrupt_data_handler corrupt_data_handler; - gms::feature_service feature_service; + std::unique_ptr feature_service_impl; + gms::feature_service& feature_service = *feature_service_impl; cache_tracker tracker; sstables::directory_semaphore dir_sem; sstables::sstables_manager sst_man; abort_source abort; - explicit sstable_manager_service(const db::config& dbcfg, sstable_compressor_factory& scf) - : corrupt_data_handler(db::corrupt_data_handler::register_metrics::no) - , feature_service({get_disabled_features_from_db_config(dbcfg)}) - , dir_sem(1) - , sst_man("schema_loader", large_data_handler, corrupt_data_handler, dbcfg, feature_service, tracker, memory::stats().total_memory(), dir_sem, []{ return locator::host_id{}; }, scf, abort) { - } + explicit sstable_manager_service(const db::config& dbcfg, sstable_compressor_factory& scf); + ~sstable_manager_service(); future<> stop() { return sst_man.close();