From 083506d479c423f2a8266bfcda26cb7436e72a6f Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Mon, 4 Sep 2023 15:36:54 +0300 Subject: [PATCH 01/15] gossiper: remove unused shadow version members Signed-off-by: Benny Halevy --- gms/gossiper.hh | 3 --- 1 file changed, 3 deletions(-) diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 1a474bb84c..0161e9382a 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -247,9 +247,6 @@ private: bool _in_shadow_round = false; - uint64_t _shadow_live_endpoints_version = 0; - uint64_t _shadow_unreachable_endpoints_version = 0; - // Must be called on shard 0. future> lock_endpoint_update_semaphore(); From 044a696aca1a190ab7d98c3ef4f178959234b580 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:31:10 +0300 Subject: [PATCH 02/15] gossiper: drop unused dump_endpoint_state_map Signed-off-by: Benny Halevy --- gms/gossiper.cc | 8 -------- gms/gossiper.hh | 2 -- 2 files changed, 10 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 489299ac85..042e373aec 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -2348,14 +2348,6 @@ clk::time_point gossiper::compute_expire_time() { return now() + A_VERY_LONG_TIME; } -void gossiper::dump_endpoint_state_map() { - logger.info("=== endpoint_state_map dump starts == "); - for (auto& x : _endpoint_state_map) { - logger.info("endpoint={}, endpoint_state={}", x.first, x.second); - } - logger.info("=== endpoint_state_map dump ends ==="); -} - bool gossiper::is_alive(inet_address ep) const { if (ep == get_broadcast_address()) { return true; diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 0161e9382a..1615d5f335 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -638,8 +638,6 @@ public: void add_expire_time_for_endpoint(inet_address endpoint, clk::time_point expire_time); static clk::time_point compute_expire_time(); -public: - void dump_endpoint_state_map(); public: bool is_seed(const inet_address& endpoint) const; bool is_shutdown(const inet_address& endpoint) const; From f7eddf0322a4820316e101247e60a6b32fa25112 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:33:23 +0300 Subject: [PATCH 03/15] gossiper: wait_for_gossip and friends: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 6 +++--- gms/gossiper.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 042e373aec..0c655570a6 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -2470,7 +2470,7 @@ std::string_view gossiper::get_gossip_status(const inet_address& endpoint) const return do_get_gossip_status(get_application_state_ptr(endpoint, application_state::STATUS)); } -future<> gossiper::wait_for_gossip(std::chrono::milliseconds initial_delay, std::optional force_after) { +future<> gossiper::wait_for_gossip(std::chrono::milliseconds initial_delay, std::optional force_after) const { static constexpr std::chrono::milliseconds GOSSIP_SETTLE_POLL_INTERVAL_MS{1000}; static constexpr int32_t GOSSIP_SETTLE_POLL_SUCCESSES_REQUIRED = 3; @@ -2512,14 +2512,14 @@ future<> gossiper::wait_for_gossip(std::chrono::milliseconds initial_delay, std: } } -future<> gossiper::wait_for_gossip_to_settle() { +future<> gossiper::wait_for_gossip_to_settle() const { auto force_after = _gcfg.skip_wait_for_gossip_to_settle; if (force_after != 0) { co_await wait_for_gossip(GOSSIP_SETTLE_MIN_WAIT_MS, force_after); } } -future<> gossiper::wait_for_range_setup() { +future<> gossiper::wait_for_range_setup() const { logger.info("Waiting for pending range setup..."); auto ring_delay = std::chrono::milliseconds(_gcfg.ring_delay_ms); auto force_after = _gcfg.skip_wait_for_gossip_to_settle; diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 1615d5f335..747ee9be24 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -654,10 +654,10 @@ public: std::string_view get_gossip_status(const endpoint_state& ep_state) const noexcept; std::string_view get_gossip_status(const inet_address& endpoint) const noexcept; public: - future<> wait_for_gossip_to_settle(); - future<> wait_for_range_setup(); + future<> wait_for_gossip_to_settle() const; + future<> wait_for_range_setup() const; private: - future<> wait_for_gossip(std::chrono::milliseconds, std::optional = {}); + future<> wait_for_gossip(std::chrono::milliseconds, std::optional = {}) const; uint64_t _nr_run = 0; uint64_t _msg_processing = 0; From 482963b2c44eefc0e01d81bec7195fb271e5b590 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:37:43 +0300 Subject: [PATCH 04/15] gossiper: is* methods: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 6 +++--- gms/gossiper.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 0c655570a6..d6d47d1870 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1397,7 +1397,7 @@ future<> gossiper::do_gossip_to_unreachable_member(gossip_digest_syn message) { return make_ready_future<>(); } -bool gossiper::is_gossip_only_member(inet_address endpoint) { +bool gossiper::is_gossip_only_member(inet_address endpoint) const { auto es = get_endpoint_state_ptr(endpoint); if (!es) { return false; @@ -2526,7 +2526,7 @@ future<> gossiper::wait_for_range_setup() const { return wait_for_gossip(ring_delay, force_after); } -bool gossiper::is_safe_for_bootstrap(inet_address endpoint) { +bool gossiper::is_safe_for_bootstrap(inet_address endpoint) const { // We allow to bootstrap a new node in only two cases: // 1) The node is a completely new node and no state in gossip at all // 2) The node has state in gossip and it is already removed from the @@ -2547,7 +2547,7 @@ bool gossiper::is_safe_for_bootstrap(inet_address endpoint) { return allowed; } -bool gossiper::is_safe_for_restart(inet_address endpoint, locator::host_id host_id) { +bool gossiper::is_safe_for_restart(inet_address endpoint, locator::host_id host_id) const { // Reject to restart a node in case: // *) if the node has been removed from the cluster by nodetool decommission or // nodetool removenode diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 747ee9be24..3c36b30da0 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -385,9 +385,9 @@ public: future get_current_generation_number(inet_address endpoint); future get_current_heart_beat_version(inet_address endpoint); - bool is_gossip_only_member(inet_address endpoint); - bool is_safe_for_bootstrap(inet_address endpoint); - bool is_safe_for_restart(inet_address endpoint, locator::host_id host_id); + bool is_gossip_only_member(inet_address endpoint) const; + bool is_safe_for_bootstrap(inet_address endpoint) const; + bool is_safe_for_restart(inet_address endpoint, locator::host_id host_id) const; private: /** * Returns true if the chosen target was also a seed. False otherwise From 02e8fdc4b8c53578750d6dc7f0ff58b40cedce63 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:45:04 +0300 Subject: [PATCH 05/15] gossiper: do_sort: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index d6d47d1870..1bdb300c6f 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -130,7 +130,7 @@ gossiper::gossiper(abort_source& as, const locator::shared_token_metadata& stm, * Sort this list. Now loop through the sorted list and retrieve the GossipDigest corresponding * to the endpoint from the map that was initially constructed. */ -void gossiper::do_sort(utils::chunked_vector& g_digest_list) { +void gossiper::do_sort(utils::chunked_vector& g_digest_list) const { /* Construct a map of endpoint to GossipDigest. */ std::map ep_to_digest_map; for (auto g_digest : g_digest_list) { diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 3c36b30da0..1cbf15f31a 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -114,7 +114,7 @@ private: future handle_get_endpoint_states_msg(gossip_get_endpoint_states_request request); static constexpr uint32_t _default_cpuid = 0; msg_addr get_msg_addr(inet_address to) const noexcept; - void do_sort(utils::chunked_vector& g_digest_list); + void do_sort(utils::chunked_vector& g_digest_list) const; timer _scheduled_gossip_task; bool _enabled = false; semaphore _callback_running{1}; From 33f004587e30973041a6795073c69bcfc2405ef1 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:50:31 +0300 Subject: [PATCH 06/15] gossiper: make_random_gossip_digest: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 1bdb300c6f..e294141333 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1224,7 +1224,7 @@ void gossiper::quarantine_endpoint(inet_address endpoint, clk::time_point quaran _just_removed_endpoints[endpoint] = quarantine_start; } -void gossiper::make_random_gossip_digest(utils::chunked_vector& g_digests) { +void gossiper::make_random_gossip_digest(utils::chunked_vector& g_digests) const { generation_type generation; version_type max_version; diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 1cbf15f31a..7ad8b2494f 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -213,7 +213,7 @@ public: std::chrono::milliseconds quarantine_delay() const noexcept; private: - std::default_random_engine _random_engine{std::random_device{}()}; + mutable std::default_random_engine _random_engine{std::random_device{}()}; /** * subscribers for interest in EndpointState change @@ -357,7 +357,7 @@ private: * * @param g_digests list of Gossip Digests. */ - void make_random_gossip_digest(utils::chunked_vector& g_digests); + void make_random_gossip_digest(utils::chunked_vector& g_digests) const; public: /** From 87ac1a26f270f96d68f0e540f9519e21fcd63eb5 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 10:50:45 +0300 Subject: [PATCH 07/15] gossiper: make_random_gossip_digest: delete dead legacy code Signed-off-by: Benny Halevy --- gms/gossiper.cc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index e294141333..e29bbf6dc7 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1243,17 +1243,6 @@ void gossiper::make_random_gossip_digest(utils::chunked_vector& g } g_digests.push_back(gossip_digest(endpoint, generation, max_version)); } -#if 0 - if (logger.isTraceEnabled()) { - StringBuilder sb = new StringBuilder(); - for (GossipDigest g_digest : g_digests) - { - sb.append(g_digest); - sb.append(" "); - } - logger.trace("Gossip Digests are : {}", sb); - } -#endif } future<> gossiper::replicate(inet_address ep, endpoint_state es, permit_id pid) { From 2899e07572f4af666ddb9862300cf56f7ffff15d Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:18:44 +0300 Subject: [PATCH 08/15] gossiper: get_state_for_version_bigger_than: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index e29bbf6dc7..c164dc1221 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1511,7 +1511,7 @@ std::set gossiper::get_nodes_with_host_id(locator::host_id ho return nodes; } -std::optional gossiper::get_state_for_version_bigger_than(inet_address for_endpoint, version_type version) { +std::optional gossiper::get_state_for_version_bigger_than(inet_address for_endpoint, version_type version) const { std::optional reqd_endpoint_state; auto es = get_endpoint_state_ptr(for_endpoint); if (es) { diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 7ad8b2494f..53bc3a5f2c 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -450,7 +450,7 @@ public: std::set get_nodes_with_host_id(locator::host_id host_id) const; - std::optional get_state_for_version_bigger_than(inet_address for_endpoint, version_type version); + std::optional get_state_for_version_bigger_than(inet_address for_endpoint, version_type version) const; /** * determine which endpoint started up earlier From 963d6fb009f1cf078cad90a6cee33c8e57cfc373 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:20:41 +0300 Subject: [PATCH 09/15] gossiper: compare_endpoint_startup: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index c164dc1221..955b4ba734 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1545,7 +1545,7 @@ std::optional gossiper::get_state_for_version_bigger_than(inet_a return reqd_endpoint_state; } -generation_type::value_type gossiper::compare_endpoint_startup(inet_address addr1, inet_address addr2) { +generation_type::value_type gossiper::compare_endpoint_startup(inet_address addr1, inet_address addr2) const { auto ep1 = get_endpoint_state_ptr(addr1); auto ep2 = get_endpoint_state_ptr(addr2); if (!ep1 || !ep2) { diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 53bc3a5f2c..08a0561fda 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -455,7 +455,7 @@ public: /** * determine which endpoint started up earlier */ - generation_type::value_type compare_endpoint_startup(inet_address addr1, inet_address addr2); + generation_type::value_type compare_endpoint_startup(inet_address addr1, inet_address addr2) const; /** * Return the rpc address associated with an endpoint as a string. From eb51b70e6dad47b320374c236e6154650a9c824b Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:24:18 +0300 Subject: [PATCH 10/15] utils: atomic_vector: mark for_each functions as const They only need to access the _vec_lock rwlock so mark it as mutable, but otherwise they provide a const interface to the calls, as the called func receives the entries by value and it cannot modify them. Signed-off-by: Benny Halevy --- utils/atomic_vector.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/atomic_vector.hh b/utils/atomic_vector.hh index 5ee801944f..4e8fe6b9f1 100644 --- a/utils/atomic_vector.hh +++ b/utils/atomic_vector.hh @@ -20,7 +20,7 @@ template class atomic_vector { std::vector _vec; - seastar::rwlock _vec_lock; + mutable seastar::rwlock _vec_lock; public: void add(const T& value) { @@ -38,7 +38,7 @@ public: // We would take callbacks that take a T&, but we had bugs in the // past with some of those callbacks holding that reference past a // preemption. - void thread_for_each(seastar::noncopyable_function func) { + void thread_for_each(seastar::noncopyable_function func) const { _vec_lock.for_read().lock().get(); auto unlock = seastar::defer([this] { _vec_lock.for_read().unlock(); @@ -56,7 +56,7 @@ public: // We would take callbacks that take a T&, but we had bugs in the // past with some of those callbacks holding that reference past a // preemption. - seastar::future<> for_each(seastar::noncopyable_function(T)> func) { + seastar::future<> for_each(seastar::noncopyable_function(T)> func) const { auto holder = co_await _vec_lock.hold_read_lock(); // We grab a lock in remove(), but not in add(), so we // iterate using indexes to guard against the vector being From cc1d5771e537aa690762e8b22a9134f946593ca1 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:25:31 +0300 Subject: [PATCH 11/15] gossiper: do_on_*notifications: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 6 +++--- gms/gossiper.hh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 955b4ba734..a7a18789b5 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1849,13 +1849,13 @@ future<> gossiper::apply_new_states(inet_address addr, endpoint_state local_stat maybe_rethrow_exception(std::move(ep)); } -future<> gossiper::do_before_change_notifications(inet_address addr, endpoint_state_ptr ep_state, const application_state& ap_state, const versioned_value& new_value) { +future<> gossiper::do_before_change_notifications(inet_address addr, endpoint_state_ptr ep_state, const application_state& ap_state, const versioned_value& new_value) const { co_await _subscribers.for_each([addr, ep_state, ap_state, new_value] (shared_ptr subscriber) { return subscriber->before_change(addr, ep_state, ap_state, new_value); }); } -future<> gossiper::do_on_change_notifications(inet_address addr, const application_state& state, const versioned_value& value, permit_id pid) { +future<> gossiper::do_on_change_notifications(inet_address addr, const application_state& state, const versioned_value& value, permit_id pid) const { co_await _subscribers.for_each([this, addr, state, value, pid] (shared_ptr subscriber) { // Once _abort_source is aborted, don't attempt to process any further notifications // because that would violate monotonicity due to partially failed notification. @@ -1864,7 +1864,7 @@ future<> gossiper::do_on_change_notifications(inet_address addr, const applicati }); } -future<> gossiper::do_on_dead_notifications(inet_address addr, endpoint_state_ptr state, permit_id pid) { +future<> gossiper::do_on_dead_notifications(inet_address addr, endpoint_state_ptr state, permit_id pid) const { co_await _subscribers.for_each([addr, state = std::move(state), pid] (shared_ptr subscriber) { return subscriber->on_dead(addr, state, pid); }); diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 08a0561fda..9490b1ffaf 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -524,15 +524,15 @@ private: // notify that a local application state is going to change (doesn't get triggered for remote changes) // Must be called under lock_endpoint. - future<> do_before_change_notifications(inet_address addr, endpoint_state_ptr ep_state, const application_state& ap_state, const versioned_value& new_value); + future<> do_before_change_notifications(inet_address addr, endpoint_state_ptr ep_state, const application_state& ap_state, const versioned_value& new_value) const; // notify that an application state has changed // Must be called under lock_endpoint. - future<> do_on_change_notifications(inet_address addr, const application_state& state, const versioned_value& value, permit_id); + future<> do_on_change_notifications(inet_address addr, const application_state& state, const versioned_value& value, permit_id) const; // notify that a node is DOWN (dead) // Must be called under lock_endpoint. - future<> do_on_dead_notifications(inet_address addr, endpoint_state_ptr state, permit_id); + future<> do_on_dead_notifications(inet_address addr, endpoint_state_ptr state, permit_id) const; /* Request all the state for the endpoint in the g_digest */ From ce05bbe32fde4d302a2f70878efedc74d1467652 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:26:27 +0300 Subject: [PATCH 12/15] gossiper: request_all, send_all: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 4 ++-- gms/gossiper.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index a7a18789b5..53331fb763 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1871,7 +1871,7 @@ future<> gossiper::do_on_dead_notifications(inet_address addr, endpoint_state_pt } void gossiper::request_all(gossip_digest& g_digest, - utils::chunked_vector& delta_gossip_digest_list, generation_type remote_generation) { + utils::chunked_vector& delta_gossip_digest_list, generation_type remote_generation) const { /* We are here since we have no data for this endpoint locally so request everthing. */ delta_gossip_digest_list.emplace_back(g_digest.get_endpoint(), remote_generation); logger.trace("request_all for {}", g_digest.get_endpoint()); @@ -1879,7 +1879,7 @@ void gossiper::request_all(gossip_digest& g_digest, void gossiper::send_all(gossip_digest& g_digest, std::map& delta_ep_state_map, - version_type max_remote_version) { + version_type max_remote_version) const { auto ep = g_digest.get_endpoint(); logger.trace("send_all(): ep={}, version > {}", ep, max_remote_version); auto local_ep_state_ptr = get_state_for_version_bigger_than(ep, max_remote_version); diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 9490b1ffaf..611b31028a 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -536,10 +536,10 @@ private: /* Request all the state for the endpoint in the g_digest */ - void request_all(gossip_digest& g_digest, utils::chunked_vector& delta_gossip_digest_list, generation_type remote_generation); + void request_all(gossip_digest& g_digest, utils::chunked_vector& delta_gossip_digest_list, generation_type remote_generation) const; /* Send all the data with version greater than max_remote_version */ - void send_all(gossip_digest& g_digest, std::map& delta_ep_state_map, version_type max_remote_version); + void send_all(gossip_digest& g_digest, std::map& delta_ep_state_map, version_type max_remote_version) const; public: /* From cfe0ec220357248f97538ec2cc9b433204423e5a Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:28:21 +0300 Subject: [PATCH 13/15] gossiper: examine_gossiper: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index 53331fb763..e1f9e01600 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1890,7 +1890,7 @@ void gossiper::send_all(gossip_digest& g_digest, void gossiper::examine_gossiper(utils::chunked_vector& g_digest_list, utils::chunked_vector& delta_gossip_digest_list, - std::map& delta_ep_state_map) { + std::map& delta_ep_state_map) const { if (g_digest_list.size() == 0) { /* we've been sent a *completely* empty syn, which should normally * never happen since an endpoint will at least send a syn with diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 611b31028a..5cd8cc95a8 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -548,7 +548,7 @@ public: */ void examine_gossiper(utils::chunked_vector& g_digest_list, utils::chunked_vector& delta_gossip_digest_list, - std::map& delta_ep_state_map); + std::map& delta_ep_state_map) const; public: /** From 43d883c5aa3725ff1fd17f8d1af1701462a8fa79 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:29:39 +0300 Subject: [PATCH 14/15] gossiper: get_generation_for_nodes: mark as const Signed-off-by: Benny Halevy --- gms/gossiper.cc | 2 +- gms/gossiper.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index e1f9e01600..ef83c255cd 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1997,7 +1997,7 @@ future<> gossiper::start_gossiping(gms::generation_type generation_nbr, std::map } future -gossiper::get_generation_for_nodes(std::unordered_set nodes) { +gossiper::get_generation_for_nodes(std::unordered_set nodes) const { generation_for_nodes ret; for (const auto& node : nodes) { auto es = get_endpoint_state_ptr(node); diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 5cd8cc95a8..0e65499a14 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -132,7 +132,7 @@ private: public: // Get current generation number for the given nodes future - get_generation_for_nodes(std::unordered_set nodes); + get_generation_for_nodes(std::unordered_set nodes) const; // Only respond echo message listed in nodes with the generation number future<> advertise_to_nodes(generation_for_nodes advertise_to_nodes = {}); const sstring& get_cluster_name() const noexcept; From 04ba560b8d203f376a221e8e56442537338e77d5 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 12:15:11 +0300 Subject: [PATCH 15/15] gossiper: get_current* methods: mark as const We need to const_cast `this` since the const container() has no const invoke_on override. Trying to fix this in seastar sharded.hh breaks many other call sites in scylla. Signed-off-by: Benny Halevy --- gms/gossiper.cc | 12 +++++++----- gms/gossiper.hh | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gms/gossiper.cc b/gms/gossiper.cc index ef83c255cd..4dd5591441 100644 --- a/gms/gossiper.cc +++ b/gms/gossiper.cc @@ -1346,14 +1346,16 @@ future<> gossiper::assassinate_endpoint(sstring address) { }); } -future gossiper::get_current_generation_number(inet_address endpoint) { - return container().invoke_on(0, [endpoint] (auto&& gossiper) { +future gossiper::get_current_generation_number(inet_address endpoint) const { + // FIXME: const container() has no const invoke_on variant + return const_cast(this)->container().invoke_on(0, [endpoint] (const gossiper& gossiper) { return gossiper.get_endpoint_state(endpoint).get_heart_beat_state().get_generation(); }); } -future gossiper::get_current_heart_beat_version(inet_address endpoint) { - return container().invoke_on(0, [endpoint] (auto&& gossiper) { +future gossiper::get_current_heart_beat_version(inet_address endpoint) const { + // FIXME: const container() has no const invoke_on variant + return const_cast(this)->container().invoke_on(0, [endpoint] (const gossiper& gossiper) { return gossiper.get_endpoint_state(endpoint).get_heart_beat_state().get_heart_beat_version(); }); } @@ -1423,7 +1425,7 @@ const endpoint_state& gossiper::get_endpoint_state(inet_address ep) const { if (it == _endpoint_state_map.end()) { throw std::out_of_range(format("ep={}", ep)); } - return const_cast(*it->second); + return *it->second; } endpoint_state& gossiper::get_or_create_endpoint_state(inet_address ep) { diff --git a/gms/gossiper.hh b/gms/gossiper.hh index 0e65499a14..7f7fb43d94 100644 --- a/gms/gossiper.hh +++ b/gms/gossiper.hh @@ -382,8 +382,8 @@ public: future<> assassinate_endpoint(sstring address); public: - future get_current_generation_number(inet_address endpoint); - future get_current_heart_beat_version(inet_address endpoint); + future get_current_generation_number(inet_address endpoint) const; + future get_current_heart_beat_version(inet_address endpoint) const; bool is_gossip_only_member(inet_address endpoint) const; bool is_safe_for_bootstrap(inet_address endpoint) const;