Merge 'Configure service levels interval' from Michał Jadwiszczak

Service level controller updates itself in interval. However the interval time is hardcoded in main to 10 seconds and it leads to long sleeps in some of the tests.

This patch moves this value to `service_levels_interval_ms` command line option and sets this value to 0.5s in cql-pytest.

Closes scylladb/scylladb#16394

* github.com:scylladb/scylladb:
  test:cql-pytest: change service levels intervals in tests
  configure service levels interval
This commit is contained in:
Botond Dénes
2024-01-17 12:24:49 +02:00
7 changed files with 18 additions and 6 deletions

View File

@@ -1127,6 +1127,7 @@ db::config::config(std::shared_ptr<db::extensions> 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)

View File

@@ -468,6 +468,8 @@ public:
named_value<std::vector<enum_option<replication_strategy_restriction_t>>> replication_strategy_warn_list;
named_value<std::vector<enum_option<replication_strategy_restriction_t>>> replication_strategy_fail_list;
named_value<uint32_t> service_levels_interval;
seastar::logging_settings logging_settings(const log_cli::options&) const;
const db::extensions& extensions() const;

View File

@@ -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<steady_clock_type::duration>(std::chrono::milliseconds(cfg->service_levels_interval()));
});
static sharded<db::system_distributed_keyspace> sys_dist_ks;
static sharded<db::system_keyspace> sys_ks;

View File

@@ -8,6 +8,7 @@
#include <seastar/core/sleep.hh>
#include <seastar/core/thread.hh>
#include "seastar/core/timer.hh"
#include "service_level_controller.hh"
#include "db/system_distributed_keyspace.hh"
#include "cql3/query_processor.hh"
@@ -269,15 +270,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<float> interval) {
void service_level_controller::update_from_distributed_data(std::function<steady_clock_type::duration()> 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<steady_clock_type>(std::chrono::duration_cast<steady_clock_type::duration>(interval),
_global_controller_db->distributed_data_update = repeat([this, interval_f = std::move(interval_f)] {
return sleep_abortable<steady_clock_type>(interval_f(),
_global_controller_db->dist_data_update_aborter).then_wrapped([this] (future<>&& f) {
try {
f.get();

View File

@@ -8,6 +8,7 @@
#pragma once
#include "seastar/core/timer.hh"
#include "seastarx.hh"
#include "auth/role_manager.hh"
#include <seastar/core/sstring.hh>
@@ -127,10 +128,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<float> interval);
void update_from_distributed_data(std::function<steady_clock_type::duration()> interval_f);
/**
* Updates the service level data from the distributed data store.

View File

@@ -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

View File

@@ -109,6 +109,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