From 33cd3b5d68adb8d0d167a618ed265221ee86d4b5 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Fri, 24 Apr 2026 15:29:39 +0300 Subject: [PATCH] alternator: Use shared updateable_timeout_config by reference Pass sharded& into alternator::controller and through to alternator::server, which now stores a reference instead of constructing its own updateable_timeout_config from proxy.data_dictionary().get_config(). This removes the last creator of a per-owner updateable_timeout_config copy and completes the consolidation onto the single sharded instance built in main. Signed-off-by: Pavel Emelyanov Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- alternator/controller.cc | 4 +++- alternator/controller.hh | 4 ++++ alternator/server.cc | 4 ++-- alternator/server.hh | 7 ++++--- main.cc | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/alternator/controller.cc b/alternator/controller.cc index 40c8388f78..94f64e408d 100644 --- a/alternator/controller.cc +++ b/alternator/controller.cc @@ -38,6 +38,7 @@ controller::controller( sharded& auth_service, sharded& sl_controller, sharded& vsc, + sharded& timeout_config, const db::config& config, seastar::scheduling_group sg) : protocol_server(sg) @@ -52,6 +53,7 @@ controller::controller( , _auth_service(auth_service) , _sl_controller(sl_controller) , _vsc(vsc) + , _timeout_config(timeout_config) , _config(config) { } @@ -99,7 +101,7 @@ future<> controller::start_server() { _executor.start(std::ref(_gossiper), std::ref(_proxy), std::ref(_ss), std::ref(_mm), std::ref(_sys_dist_ks), std::ref(_sys_ks), sharded_parameter(get_cdc_metadata, std::ref(_cdc_gen_svc)), std::ref(_vsc), _ssg.value(), sharded_parameter(get_timeout_in_ms, std::ref(_config))).get(); - _server.start(std::ref(_executor), std::ref(_proxy), std::ref(_gossiper), std::ref(_auth_service), std::ref(_sl_controller)).get(); + _server.start(std::ref(_executor), std::ref(_proxy), std::ref(_gossiper), std::ref(_auth_service), std::ref(_sl_controller), std::ref(_timeout_config)).get(); // Note: from this point on, if start_server() throws for any reason, // it must first call stop_server() to stop the executor and server // services we just started - or Scylla will cause an assertion diff --git a/alternator/controller.hh b/alternator/controller.hh index cd8bdf7f55..f058720e50 100644 --- a/alternator/controller.hh +++ b/alternator/controller.hh @@ -48,6 +48,8 @@ namespace vector_search { class vector_store_client; } +class updateable_timeout_config; + namespace alternator { // This is the official DynamoDB API version. @@ -72,6 +74,7 @@ class controller : public protocol_server { sharded& _auth_service; sharded& _sl_controller; sharded& _vsc; + sharded& _timeout_config; const db::config& _config; std::vector _listen_addresses; @@ -92,6 +95,7 @@ public: sharded& auth_service, sharded& sl_controller, sharded& vsc, + sharded& timeout_config, const db::config& config, seastar::scheduling_group sg); diff --git a/alternator/server.cc b/alternator/server.cc index 68f7cacf7a..6c932808b8 100644 --- a/alternator/server.cc +++ b/alternator/server.cc @@ -835,7 +835,7 @@ void server::set_routes(routes& r) { //FIXME: A way to immediately invalidate the cache should be considered, // e.g. when the system table which stores the keys is changed. // For now, this propagation may take up to 1 minute. -server::server(executor& exec, service::storage_proxy& proxy, gms::gossiper& gossiper, auth::service& auth_service, qos::service_level_controller& sl_controller) +server::server(executor& exec, service::storage_proxy& proxy, gms::gossiper& gossiper, auth::service& auth_service, qos::service_level_controller& sl_controller, updateable_timeout_config& timeout_config) : _http_server("http-alternator") , _https_server("https-alternator") , _executor(exec) @@ -847,7 +847,7 @@ server::server(executor& exec, service::storage_proxy& proxy, gms::gossiper& gos , _max_users_query_size_in_trace_output(1024) , _enabled_servers{} , _pending_requests("alternator::server::pending_requests") - , _timeout_config(_proxy.data_dictionary().get_config()) + , _timeout_config(timeout_config) , _callbacks{ {"CreateTable", [] (executor& e, executor::client_state& client_state, tracing::trace_state_ptr trace_state, service_permit permit, rjson::value json_request, std::unique_ptr req, std::unique_ptr& audit_info) { return e.create_table(client_state, std::move(trace_state), std::move(permit), std::move(json_request), audit_info); diff --git a/alternator/server.hh b/alternator/server.hh index f105510bcc..26db39a044 100644 --- a/alternator/server.hh +++ b/alternator/server.hh @@ -16,6 +16,7 @@ #include #include #include "alternator/auth.hh" +#include "timeout_config.hh" #include "service/qos/service_level_controller.hh" #include "utils/small_vector.hh" #include "utils/updateable_value.hh" @@ -53,8 +54,8 @@ class server : public peering_sharded_service { named_gate _pending_requests; // In some places we will need a CQL updateable_timeout_config object even // though it isn't really relevant for Alternator which defines its own - // timeouts separately. We can create this object only once. - updateable_timeout_config _timeout_config; + // timeouts separately. + updateable_timeout_config& _timeout_config; client_options_cache_type _connection_options_keys_and_values; alternator_callbacks_map _callbacks; @@ -98,7 +99,7 @@ class server : public peering_sharded_service { utils::scoped_item_list _ongoing_requests; public: - server(executor& executor, service::storage_proxy& proxy, gms::gossiper& gossiper, auth::service& service, qos::service_level_controller& sl_controller); + server(executor& executor, service::storage_proxy& proxy, gms::gossiper& gossiper, auth::service& service, qos::service_level_controller& sl_controller, updateable_timeout_config& timeout_config); future<> init(net::inet_address addr, std::optional port, std::optional https_port, std::optional port_proxy_protocol, std::optional https_port_proxy_protocol, diff --git a/main.cc b/main.cc index b78a8ba228..d1feceb0f9 100644 --- a/main.cc +++ b/main.cc @@ -2616,7 +2616,7 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl api::set_server_service_levels(ctx, cql_server_ctl, qp).get(); - alternator::controller alternator_ctl(gossiper, proxy, ss, mm, sys_dist_ks, sys_ks, cdc_generation_service, service_memory_limiter, auth_service, sl_controller, vector_store_client, *cfg, dbcfg.statement_scheduling_group); + alternator::controller alternator_ctl(gossiper, proxy, ss, mm, sys_dist_ks, sys_ks, cdc_generation_service, service_memory_limiter, auth_service, sl_controller, vector_store_client, timeout_cfg, *cfg, dbcfg.statement_scheduling_group); // Register at_exit last, so that storage_service::drain_on_shutdown will be called first auto do_drain = defer_verbose_shutdown("local storage", [&ss] {