From c46c57d535979d42ff55f7ecba68a863ae346a30 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 11 Jul 2023 13:29:53 +0300 Subject: [PATCH] messaging_service: Clear list of clients on shutdown When messaging_service shuts down it first sets _shutting_down to true and proceeds with stopping clients and servers. Stopping clients, in turn, is calling client.stop() on each. Setting _shutting_down is used in two places. First, when a client is stopped it may happen that it's in the middle of some operation, which may result in call to remove_error_rpc_client() and not to call .stop() for the second time it just does nothing if the shutdown flag is set (see 357c91a076). Second, get_rpc_client() asserts that this flag is not set, so once shutdown started it can make sure that it will call .stop() on _all_ clients and no new ones would appear in parallel. However, after shutdown() is complete the _clients vector of maps remains intact even though all clients from it are stopped. This is not very debugging-friendly, the clients are better be removed on shutdown. fixes: #14624 Signed-off-by: Pavel Emelyanov Closes #14632 --- message/messaging_service.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/message/messaging_service.cc b/message/messaging_service.cc index 1216a913a299..5238322474c7 100644 --- a/message/messaging_service.cc +++ b/message/messaging_service.cc @@ -485,6 +485,11 @@ future<> messaging_service::stop_client() { return c.second.rpc_client->stop().then([addr = c.first] { mlogger.info("Stopping client for address: {} - Done", addr); }); + }).finally([&m] { + // no new clients should be added by get_rpc_client(), as it + // asserts that _shutting_down is true + m.clear(); + mlogger.info("Stopped clients"); }); }); }