storage_service: drop check_for_endpoint_collision function

All the checks that it does are also done by join coordinator and the
join coordinator uses more reliable raft state instead of gossiper one.
This commit is contained in:
Gleb Natapov
2026-03-23 12:37:41 +02:00
parent 1ac8edb22b
commit c17c4806a1
4 changed files with 1 additions and 52 deletions

View File

@@ -2331,31 +2331,6 @@ std::string_view gossiper::get_gossip_status(const locator::host_id& endpoint) c
return do_get_gossip_status(get_application_state_ptr(endpoint, application_state::STATUS));
}
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
// cluster either by nodetool decommission or nodetool removenode
bool allowed = true;
auto host_id = try_get_host_id(endpoint);
if (!host_id) {
logger.debug("is_safe_for_bootstrap: node={}, status=no state in gossip, allowed_to_bootstrap={}", endpoint, allowed);
return allowed;
}
auto eps = get_endpoint_state_ptr(*host_id);
if (!eps) {
logger.debug("is_safe_for_bootstrap: node={}, status=no state in gossip, allowed_to_bootstrap={}", endpoint, allowed);
return allowed;
}
auto status = get_gossip_status(*eps);
std::unordered_set<std::string_view> allowed_statuses{
versioned_value::STATUS_LEFT,
};
allowed = allowed_statuses.contains(status);
logger.debug("is_safe_for_bootstrap: node={}, status={}, allowed_to_bootstrap={}", endpoint, status, allowed);
return allowed;
}
std::set<sstring> gossiper::get_supported_features(locator::host_id endpoint) const {
auto app_state = get_application_state_ptr(endpoint, application_state::SUPPORTED_FEATURES);
if (!app_state) {

View File

@@ -352,7 +352,6 @@ public:
future<generation_type> get_current_generation_number(locator::host_id endpoint) const;
future<version_type> get_current_heart_beat_version(locator::host_id endpoint) const;
bool is_safe_for_bootstrap(inet_address endpoint) const;
private:
/**
* Returns true if the chosen target was also a seed. False otherwise

View File

@@ -1551,9 +1551,7 @@ future<> storage_service::join_topology(sharded<service::storage_proxy>& proxy,
raft_replace_info = raft_group0::replace_info {
.raft_id = raft::server_id{ri->host_id.uuid()},
};
} else if (!_sys_ks.local().bootstrap_complete()) {
co_await check_for_endpoint_collision(initial_contact_nodes);
} else {
} else if (_sys_ks.local().bootstrap_complete()) {
slogger.info("Performing gossip shadow round, initial_contact_nodes={}", initial_contact_nodes);
co_await _gossiper.do_shadow_round(initial_contact_nodes, gms::gossiper::mandatory::no);
_gossiper.check_snitch_name_matches(_snitch.local()->get_name());
@@ -2401,27 +2399,6 @@ future<> storage_service::wait_for_group0_stop() {
}
}
future<> storage_service::check_for_endpoint_collision(std::unordered_set<gms::inet_address> initial_contact_nodes) {
slogger.debug("Starting shadow gossip round to check for endpoint collision");
return seastar::async([this, initial_contact_nodes] {
bool found_bootstrapping_node = false;
auto local_features = _feature_service.supported_feature_set();
do {
slogger.info("Performing gossip shadow round");
_gossiper.do_shadow_round(initial_contact_nodes, gms::gossiper::mandatory::yes).get();
_gossiper.check_snitch_name_matches(_snitch.local()->get_name());
auto addr = get_broadcast_address();
if (!_gossiper.is_safe_for_bootstrap(addr)) {
throw std::runtime_error(::format("A node with address {} already exists, cancelling join. "
"Use replace_address if you want to replace this node.", addr));
}
} while (found_bootstrapping_node);
slogger.info("Checking bootstrapping/leaving/moving nodes: ok (check_for_endpoint_collision)");
_gossiper.reset_endpoint_state_map().get();
});
}
future<> storage_service::remove_endpoint(inet_address endpoint, gms::permit_id pid) {
auto host_id_opt = _gossiper.try_get_host_id(endpoint);
if (host_id_opt) {

View File

@@ -474,8 +474,6 @@ private:
public:
future<> check_for_endpoint_collision(std::unordered_set<gms::inet_address> initial_contact_nodes);
future<> join_cluster(sharded<service::storage_proxy>& proxy,
start_hint_manager start_hm, gms::generation_type new_generation);