From f6a464ad81907029a05c191fdfa104d899cd8c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jadwiszczak?= Date: Mon, 11 Dec 2023 18:40:28 +0100 Subject: [PATCH 1/2] configure service levels interval So far the service levels interval, responsible for updating SL configuration, was hardcoded in main. Now it's extracted to `service_levels_interval_ms` option. --- db/config.cc | 1 + db/config.hh | 2 ++ main.cc | 5 ++++- service/qos/service_level_controller.cc | 7 ++++--- service/qos/service_level_controller.hh | 6 ++++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/db/config.cc b/db/config.cc index 441e4a6f7d..e7aa777a14 100644 --- a/db/config.cc +++ b/db/config.cc @@ -1127,6 +1127,7 @@ db::config::config(std::shared_ptr exts) , maximum_replication_factor_fail_threshold(this, "maximum_replication_factor_fail_threshold", liveness::LiveUpdate, value_status::Used, -1, "") , replication_strategy_warn_list(this, "replication_strategy_warn_list", liveness::LiveUpdate, value_status::Used, {locator::replication_strategy_type::simple}, "Controls which replication strategies to warn about when creating/altering a keyspace. Doesn't affect the pre-existing keyspaces.") , replication_strategy_fail_list(this, "replication_strategy_fail_list", liveness::LiveUpdate, value_status::Used, {}, "Controls which replication strategies are disallowed to be used when creating/altering a keyspace. Doesn't affect the pre-existing keyspaces.") + , service_levels_interval(this, "service_levels_interval_ms", liveness::LiveUpdate, value_status::Used, 10000, "Controls how often service levels module polls configuration table") , error_injections_at_startup(this, "error_injections_at_startup", error_injection_value_status, {}, "List of error injections that should be enabled on startup.") , default_log_level(this, "default_log_level", value_status::Used) , logger_log_level(this, "logger_log_level", value_status::Used) diff --git a/db/config.hh b/db/config.hh index 0fd5b34e31..7a6ab6486f 100644 --- a/db/config.hh +++ b/db/config.hh @@ -468,6 +468,8 @@ public: named_value>> replication_strategy_warn_list; named_value>> replication_strategy_fail_list; + named_value service_levels_interval; + seastar::logging_settings logging_settings(const log_cli::options&) const; const db::extensions& extensions() const; diff --git a/main.cc b/main.cc index b60eece47a..c2b5e27295 100644 --- a/main.cc +++ b/main.cc @@ -16,6 +16,7 @@ #include "auth/allow_all_authenticator.hh" #include "auth/allow_all_authorizer.hh" #include "auth/maintenance_socket_role_manager.hh" +#include "seastar/core/timer.hh" #include "tasks/task_manager.hh" #include "utils/build_id.hh" #include "supervisor.hh" @@ -1152,7 +1153,9 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl }); //This starts the update loop - but no real update happens until the data accessor is not initialized. - sl_controller.local().update_from_distributed_data(std::chrono::seconds(10)); + sl_controller.local().update_from_distributed_data([cfg] () { + return std::chrono::duration_cast(std::chrono::milliseconds(cfg->service_levels_interval())); + }); static sharded sys_dist_ks; static sharded sys_ks; diff --git a/service/qos/service_level_controller.cc b/service/qos/service_level_controller.cc index 64d3c82a44..89d1129f60 100644 --- a/service/qos/service_level_controller.cc +++ b/service/qos/service_level_controller.cc @@ -9,6 +9,7 @@ #include #include #include +#include "seastar/core/timer.hh" #include "service_level_controller.hh" #include "message/messaging_service.hh" #include "db/system_distributed_keyspace.hh" @@ -271,15 +272,15 @@ future<> service_level_controller::notify_service_level_removed(sstring name) { return make_ready_future<>(); } -void service_level_controller::update_from_distributed_data(std::chrono::duration interval) { +void service_level_controller::update_from_distributed_data(std::function interval_f) { if (this_shard_id() != global_controller) { throw std::runtime_error(format("Service level updates from distributed data can only be activated on shard {}", global_controller)); } if (_global_controller_db->distributed_data_update.available()) { sl_logger.info("update_from_distributed_data: starting configuration polling loop"); _logged_intervals = 0; - _global_controller_db->distributed_data_update = repeat([this, interval] { - return sleep_abortable(std::chrono::duration_cast(interval), + _global_controller_db->distributed_data_update = repeat([this, interval_f = std::move(interval_f)] { + return sleep_abortable(interval_f(), _global_controller_db->dist_data_update_aborter).then_wrapped([this] (future<>&& f) { try { f.get(); diff --git a/service/qos/service_level_controller.hh b/service/qos/service_level_controller.hh index a71f01a1cf..3e72d72e53 100644 --- a/service/qos/service_level_controller.hh +++ b/service/qos/service_level_controller.hh @@ -8,6 +8,7 @@ #pragma once +#include "seastar/core/timer.hh" #include "seastarx.hh" #include "log.hh" #include "auth/role_manager.hh" @@ -130,10 +131,11 @@ public: * Chack the distributed data for changes in a constant interval and updates * the service_levels configuration in accordance (adds, removes, or updates * service levels as necessairy). - * @param interval - the interval is seconds to check the distributed data. + * @param interval_f - lambda function which returns a interval in miliseconds. + The interval is time to check the distributed data. * @return a future that is resolved when the update loop stops. */ - void update_from_distributed_data(std::chrono::duration interval); + void update_from_distributed_data(std::function interval_f); /** * Updates the service level data from the distributed data store. From 013487e1e17db23640b1dd8709709e0c09c4366a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Jadwiszczak?= Date: Tue, 9 Jan 2024 08:53:38 +0100 Subject: [PATCH 2/2] test:cql-pytest: change service levels intervals in tests Set the interval to 0.5s to reduce required sleep time. --- test/cql-pytest/run.py | 1 + test/pylib/scylla_cluster.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/cql-pytest/run.py b/test/cql-pytest/run.py index 3d7d5f9720..14fd416518 100755 --- a/test/cql-pytest/run.py +++ b/test/cql-pytest/run.py @@ -322,6 +322,7 @@ def run_scylla_cmd(pid, dir): '--permissions-validity-in-ms', '100', '--shutdown-announce-in-ms', '0', '--maintenance-socket', 'workdir', + '--service-levels-interval-ms', '500', ], env) # Same as run_scylla_cmd, just use SSL encryption for the CQL port (same diff --git a/test/pylib/scylla_cluster.py b/test/pylib/scylla_cluster.py index 30d167ed4c..1553431265 100644 --- a/test/pylib/scylla_cluster.py +++ b/test/pylib/scylla_cluster.py @@ -110,6 +110,8 @@ def make_scylla_conf(workdir: pathlib.Path, host_addr: str, seed_addrs: List[str 'reader_concurrency_semaphore_kill_limit_multiplier': 0, 'maintenance_socket': 'workdir', + + 'service_levels_interval_ms': 500, } # Seastar options can not be passed through scylla.yaml, use command line