storage_service: handle_state_bootstrap: update new token_metadata

This commit is contained in:
Petr Gusev
2023-10-22 20:09:51 +04:00
parent 4e03ba3ede
commit 5c04a47d6f

View File

@@ -3668,21 +3668,29 @@ future<> storage_service::handle_state_bootstrap(inet_address endpoint, gms::per
// continue. // continue.
auto tmlock = co_await get_token_metadata_lock(); auto tmlock = co_await get_token_metadata_lock();
auto tmptr = co_await get_mutable_token_metadata_ptr(); auto tmptr = co_await get_mutable_token_metadata_ptr();
if (tmptr->is_normal_token_owner(endpoint)) { auto update_tm = [&]<typename NodeId>(locator::generic_token_metadata<NodeId>& tm, NodeId n, std::optional<locator::endpoint_dc_rack> dc_rack) {
// If isLeaving is false, we have missed both LEAVING and LEFT. However, if if (tm.is_normal_token_owner(n)) {
// isLeaving is true, we have only missed LEFT. Waiting time between completing // If isLeaving is false, we have missed both LEAVING and LEFT. However, if
// leave operation and rebootstrapping is relatively short, so the latter is quite // isLeaving is true, we have only missed LEFT. Waiting time between completing
// common (not enough time for gossip to spread). Therefore we report only the // leave operation and rebootstrapping is relatively short, so the latter is quite
// former in the log. // common (not enough time for gossip to spread). Therefore we report only the
if (!tmptr->is_leaving(endpoint)) { // former in the log.
slogger.info("Node {} state jump to bootstrap", endpoint); if (!tm.is_leaving(n)) {
slogger.info("Node {} state jump to bootstrap", n);
}
tm.remove_endpoint(n);
} }
tmptr->remove_endpoint(endpoint);
}
tmptr->update_topology(endpoint, get_dc_rack_for(endpoint), locator::node::state::bootstrapping); tm.update_topology(n, dc_rack, locator::node::state::bootstrapping);
tmptr->add_bootstrap_tokens(tokens, endpoint); tm.add_bootstrap_tokens(tokens, n);
tmptr->update_host_id(_gossiper.get_host_id(endpoint), endpoint); };
const auto dc_rack = get_dc_rack_for(endpoint);
const auto host_id = _gossiper.get_host_id(endpoint);
update_tm(*tmptr, endpoint, dc_rack);
update_tm(*tmptr->get_new(), host_id, dc_rack);
tmptr->update_host_id(host_id, endpoint);
tmptr->get_new()->update_host_id(host_id, endpoint);
co_await update_topology_change_info(tmptr, ::format("handle_state_bootstrap {}", endpoint)); co_await update_topology_change_info(tmptr, ::format("handle_state_bootstrap {}", endpoint));
co_await replicate_to_all_cores(std::move(tmptr)); co_await replicate_to_all_cores(std::move(tmptr));
} }