From d59db94f3cca2738318087d237d0a9cf3c4252de Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Fri, 19 Jan 2024 20:18:17 +0100 Subject: [PATCH] raft topology: Introduce param-less topology::get_excluded_nodes() Picks up currently excluded nodes. Will be used during tablet rebuild on removenode. --- service/topology_state_machine.cc | 19 +++++++++++++++++++ service/topology_state_machine.hh | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/service/topology_state_machine.cc b/service/topology_state_machine.cc index 43e3d94578..8a398bf112 100644 --- a/service/topology_state_machine.cc +++ b/service/topology_state_machine.cc @@ -88,6 +88,25 @@ std::optional topology::get_request_param(raft::server_id id) con return std::nullopt; }; +std::unordered_set topology::get_excluded_nodes() const { + std::unordered_set result; + + for (auto& [id, rs] : transition_nodes) { + std::optional req; + auto req_i = requests.find(id); + if (req_i != requests.end()) { + req = req_i->second; + } + if (rs.state == node_state::removing) { + result.insert(id); + } + auto excluded = get_excluded_nodes(id, req, get_request_param(id)); + result.insert(excluded.begin(), excluded.end()); + } + + return result; +} + std::set calculate_not_yet_enabled_features(const std::set& enabled_features, const auto& supported_features) { std::set to_enable; bool first = true; diff --git a/service/topology_state_machine.hh b/service/topology_state_machine.hh index d0ea7ad626..093bfc5085 100644 --- a/service/topology_state_machine.hh +++ b/service/topology_state_machine.hh @@ -177,6 +177,10 @@ struct topology { // Returns false iff we can safely start a new topology change. bool is_busy() const; + // Returns the set of nodes currently excluded from synchronization-with in the topology. + // Barrier should not wait for those nodes. + std::unordered_set get_excluded_nodes() const; + std::optional get_request_param(raft::server_id) const; static raft::server_id parse_replaced_node(const std::optional&); static std::unordered_set parse_ignore_nodes(const std::optional&);