From c61d0ee8aaba8bebdca031caa42660366574934f Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Wed, 30 Jan 2019 15:01:25 +0100 Subject: [PATCH] main: register storage proxy as lifecycle subscriber In order to be able to act when node joins/leaves, storage proxy is registered as an endpoint lifecycle subscriber. Fixes #3826 Fixes #4028 --- main.cc | 4 +++- service/storage_service.cc | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.cc b/main.cc index 23f52bd9a0..cc10cce3aa 100644 --- a/main.cc +++ b/main.cc @@ -767,7 +767,9 @@ int main(int ac, char** av) { db::hints::manager::rebalance(cfg->view_hints_directory()).get(); proxy.invoke_on_all([] (service::storage_proxy& local_proxy) { - local_proxy.start_hints_manager(gms::get_local_gossiper().shared_from_this(), service::get_local_storage_service().shared_from_this()); + auto& ss = service::get_local_storage_service(); + ss.register_subscriber(&local_proxy); + local_proxy.start_hints_manager(gms::get_local_gossiper().shared_from_this(), ss.shared_from_this()); }).get(); supervisor::notify("starting messaging service"); diff --git a/service/storage_service.cc b/service/storage_service.cc index cca6df7f18..3b46fd0ab5 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -1383,7 +1383,8 @@ future<> storage_service::drain_on_shutdown() { ss._sys_dist_ks.invoke_on_all(&db::system_distributed_keyspace::stop).get(); slogger.info("Drain on shutdown: system distributed keyspace stopped"); - get_storage_proxy().invoke_on_all([] (storage_proxy& local_proxy) { + get_storage_proxy().invoke_on_all([&ss] (storage_proxy& local_proxy) mutable { + ss.unregister_subscriber(&local_proxy); return local_proxy.stop_hints_manager(); }).get(); slogger.info("Drain on shutdown: hints manager is stopped");