Merge 'main: reload service levels data accessor after join_cluster' from Marcin Maliszkiewicz

Setting data accessor implicitly depends on node joining the cluster
with raft leader elected as only then service level mutation is put
into scylla_local table. Calling it after join_cluster avoids starting
new cluster with older version only to immediately migrate it to the
latest one in the background.

Closes scylladb/scylladb#18040

* github.com:scylladb/scylladb:
  main: reload service levels data accessor after join_cluster
  service: qos: create separate function for reloading data accessor
This commit is contained in:
Piotr Dulikowski
2024-03-29 09:39:11 +01:00
3 changed files with 23 additions and 10 deletions

18
main.cc
View File

@@ -1792,16 +1792,6 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
*/
db.local().enable_autocompaction_toggle();
sl_controller.invoke_on_all([&qp, &group0_client] (qos::service_level_controller& controller) -> future<> {
return qos::get_service_level_distributed_data_accessor_for_current_version(
sys_ks.local(),
sys_dist_ks.local(),
qp.local(), group0_client
).then([&controller] (auto data_accessor) {
controller.set_distributed_data_accessor(std::move(data_accessor));
});
}).get();
group0_service.start().get();
auto stop_group0_service = defer_verbose_shutdown("group 0 service", [&group0_service] {
sl_controller.local().abort_group0_operations();
@@ -1847,6 +1837,14 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl
startlog.info("SSTable data integrity checker is {}.",
cfg->enable_sstable_data_integrity_check() ? "enabled" : "disabled");
// This implicitly depends on node joining the cluster (join_cluster())
// with raft leader elected as only then service level mutation is put
// into scylla_local table. Calling it here avoids starting new cluster with
// older version only to immediately migrate it to the latest in the background.
sl_controller.invoke_on_all([&qp, &group0_client] (qos::service_level_controller& controller) -> future<> {
return controller.reload_distributed_data_accessor(
qp.local(), group0_client, sys_ks.local(), sys_dist_ks.local());
}).get();
const qualified_name qualified_authorizer_name(auth::meta::AUTH_PACKAGE_NAME, cfg->authorizer());
const qualified_name qualified_authenticator_name(auth::meta::AUTH_PACKAGE_NAME, cfg->authenticator());

View File

@@ -88,6 +88,15 @@ void service_level_controller::set_distributed_data_accessor(service_level_distr
}
}
future<> service_level_controller::reload_distributed_data_accessor(cql3::query_processor& qp, service::raft_group0_client& g0, db::system_keyspace& sys_ks, db::system_distributed_keyspace& sys_dist_ks) {
auto accesor = co_await qos::get_service_level_distributed_data_accessor_for_current_version(
sys_ks,
sys_dist_ks,
qp,
g0);
set_distributed_data_accessor(std::move(accesor));
}
future<> service_level_controller::drain() {
if (this_shard_id() != global_controller) {
co_return;

View File

@@ -105,6 +105,12 @@ public:
void set_distributed_data_accessor(service_level_distributed_data_accessor_ptr sl_data_accessor);
/**
* Reloads data accessor, this is used to align it with service level version
* stored in scylla_local table.
*/
future<> reload_distributed_data_accessor(cql3::query_processor&, service::raft_group0_client&, db::system_keyspace&, db::system_distributed_keyspace&);
/**
* Adds a service level configuration if it doesn't exists, and updates
* an the existing one if it does exist.