From 17294a3bc76b35239080fbe85839deaefe9fdfaf Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Wed, 28 Oct 2015 19:55:06 +0200 Subject: [PATCH] locator::gossiping_property_file_snitch: fix some issues in reload_configuration() - Invoke reload_gossiper_state() and gossip_snitch_info() on CPU0 since gossiper is effectively running on CPU0 therefore all methods modifying its state should be invoked on CPU0 as well. - Don't invoke any method on external "distributed" objects unless their corresponding per-shard service object have already been initialized. - Update a local Node info in a storage_service::token_metadata::topology when reloading snitch configuration when DC and/or Rack info has changed. Signed-off-by: Vlad Zolotarov --- locator/gossiping_property_file_snitch.cc | 35 +++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/locator/gossiping_property_file_snitch.cc b/locator/gossiping_property_file_snitch.cc index 8378b93d9e..8efeae378b 100644 --- a/locator/gossiping_property_file_snitch.cc +++ b/locator/gossiping_property_file_snitch.cc @@ -209,15 +209,34 @@ future<> gossiping_property_file_snitch::reload_configuration() { local_s->set_my_rack(_my_rack); } }).then([this] { - reload_gossiper_state(); + return seastar::async([this] { + // reload Gossiper state (executed on CPU0 only) + smp::submit_to(0, [this] { + this->reload_gossiper_state(); + }).get(); - return service::get_storage_service().invoke_on_all( - [] (service::storage_service& l) { - l.get_token_metadata().invalidate_cached_rings(); - }).then([this] { - if (_gossip_started) { - service::get_local_storage_service().gossip_snitch_info(); - } + // update Storage Service on each shard + auto cpus = boost::irange(0u, smp::count); + parallel_for_each(cpus.begin(), cpus.end(), [] (unsigned int c) { + return smp::submit_to(c, [] { + if (service::get_storage_service().local_is_initialized()) { + auto& tmd = service::get_local_storage_service().get_token_metadata(); + + // initiate the token metadata endpoints cache reset + tmd.invalidate_cached_rings(); + // re-read local rack and DC info + tmd.update_topology(utils::fb_utilities::get_broadcast_address()); + } + }); + }).get(); + + + // spread the word... + smp::submit_to(0, [this] { + if (this->_gossip_started && service::get_storage_service().local_is_initialized()) { + service::get_local_storage_service().gossip_snitch_info(); + } + }).get(); }); }); }