From 456dbc122b8aea6ab08dfbf91c6d3857d7cd75cb Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 10 Jul 2024 12:52:06 +0300 Subject: [PATCH] api: Unset cache_service endpoints on stop They currently stay registered long after the dependent services get stopped. There's a need for batch unsetting (scylladb/seastar#1620), so currently only this explicit listing :( Signed-off-by: Pavel Emelyanov --- api/api.cc | 4 ++++ api/api_init.hh | 1 + api/cache_service.cc | 45 ++++++++++++++++++++++++++++++++++++++++++++ api/cache_service.hh | 1 + main.cc | 3 +++ 5 files changed, 54 insertions(+) diff --git a/api/api.cc b/api/api.cc index e92cd14591..1cfa638636 100644 --- a/api/api.cc +++ b/api/api.cc @@ -258,6 +258,10 @@ future<> set_server_cache(http_context& ctx) { "The cache service API", set_cache_service); } +future<> unset_server_cache(http_context& ctx) { + return ctx.http_server.set_routes([&ctx] (routes& r) { unset_cache_service(ctx, r); }); +} + future<> set_hinted_handoff(http_context& ctx, sharded& proxy) { return register_api(ctx, "hinted_handoff", "The hinted handoff API", [&proxy] (http_context& ctx, routes& r) { diff --git a/api/api_init.hh b/api/api_init.hh index e0fc19d618..b9abb30d50 100644 --- a/api/api_init.hh +++ b/api/api_init.hh @@ -119,6 +119,7 @@ future<> unset_server_stream_manager(http_context& ctx); future<> set_hinted_handoff(http_context& ctx, sharded& p); future<> unset_hinted_handoff(http_context& ctx); future<> set_server_cache(http_context& ctx); +future<> unset_server_cache(http_context& ctx); future<> set_server_compaction_manager(http_context& ctx); future<> set_server_done(http_context& ctx); future<> set_server_task_manager(http_context& ctx, sharded& tm, lw_shared_ptr cfg); diff --git a/api/cache_service.cc b/api/cache_service.cc index 425704a9cb..fa16e5e95e 100644 --- a/api/cache_service.cc +++ b/api/cache_service.cc @@ -320,5 +320,50 @@ void set_cache_service(http_context& ctx, routes& r) { }); } +void unset_cache_service(http_context& ctx, routes& r) { + cs::get_row_cache_save_period_in_seconds.unset(r); + cs::set_row_cache_save_period_in_seconds.unset(r); + cs::get_key_cache_save_period_in_seconds.unset(r); + cs::set_key_cache_save_period_in_seconds.unset(r); + cs::get_counter_cache_save_period_in_seconds.unset(r); + cs::set_counter_cache_save_period_in_seconds.unset(r); + cs::get_row_cache_keys_to_save.unset(r); + cs::set_row_cache_keys_to_save.unset(r); + cs::get_key_cache_keys_to_save.unset(r); + cs::set_key_cache_keys_to_save.unset(r); + cs::get_counter_cache_keys_to_save.unset(r); + cs::set_counter_cache_keys_to_save.unset(r); + cs::invalidate_key_cache.unset(r); + cs::invalidate_counter_cache.unset(r); + cs::set_row_cache_capacity_in_mb.unset(r); + cs::set_key_cache_capacity_in_mb.unset(r); + cs::set_counter_cache_capacity_in_mb.unset(r); + cs::save_caches.unset(r); + cs::get_key_capacity.unset(r); + cs::get_key_hits.unset(r); + cs::get_key_requests.unset(r); + cs::get_key_hit_rate.unset(r); + cs::get_key_hits_moving_avrage.unset(r); + cs::get_key_requests_moving_avrage.unset(r); + cs::get_key_size.unset(r); + cs::get_key_entries.unset(r); + cs::get_row_capacity.unset(r); + cs::get_row_hits.unset(r); + cs::get_row_requests.unset(r); + cs::get_row_hit_rate.unset(r); + cs::get_row_hits_moving_avrage.unset(r); + cs::get_row_requests_moving_avrage.unset(r); + cs::get_row_size.unset(r); + cs::get_row_entries.unset(r); + cs::get_counter_capacity.unset(r); + cs::get_counter_hits.unset(r); + cs::get_counter_requests.unset(r); + cs::get_counter_hit_rate.unset(r); + cs::get_counter_hits_moving_avrage.unset(r); + cs::get_counter_requests_moving_avrage.unset(r); + cs::get_counter_size.unset(r); + cs::get_counter_entries.unset(r); +} + } diff --git a/api/cache_service.hh b/api/cache_service.hh index 0165ec3e0d..ac438af3bc 100644 --- a/api/cache_service.hh +++ b/api/cache_service.hh @@ -16,5 +16,6 @@ namespace api { struct http_context; void set_cache_service(http_context& ctx, seastar::httpd::routes& r); +void unset_cache_service(http_context& ctx, seastar::httpd::routes& r); } diff --git a/main.cc b/main.cc index 140565fe78..75ea339aa2 100644 --- a/main.cc +++ b/main.cc @@ -1829,6 +1829,9 @@ To start the scylla server proper, simply invoke as: scylla server (or just scyl }); api::set_server_cache(ctx).get(); + auto stop_cache_api = defer_verbose_shutdown("cache API", [&ctx] { + api::unset_server_cache(ctx).get(); + }); if (cfg->maintenance_mode()) { startlog.info("entering maintenance mode.");