token_metadata: Prune empty racks on endpoint change

Fixes #6459

When moving or removing endpoints, we should ensure
that the set of available racks reflect the nodes
known, i.e. match what would be the result of a
reboot + create sets initially.
Message-Id: <20200519153300.15391-1-calle@scylladb.com>
This commit is contained in:
Calle Wilund
2020-05-19 15:33:00 +00:00
committed by Tomasz Grabiec
parent 0673e44fc1
commit 7ce4a8b458

View File

@@ -1975,9 +1975,7 @@ void topology::add_endpoint(const inet_address& ep)
if (current->second.dc == dc && current->second.rack == rack) {
return;
}
_dc_racks[current->second.dc][current->second.rack].erase(ep);
_dc_endpoints[current->second.dc].erase(ep);
remove_endpoint(ep);
}
_dc_endpoints[dc].insert(ep);
@@ -2002,7 +2000,14 @@ void topology::remove_endpoint(inet_address ep)
}
_dc_endpoints[cur_dc_rack->second.dc].erase(ep);
_dc_racks[cur_dc_rack->second.dc][cur_dc_rack->second.rack].erase(ep);
auto& racks = _dc_racks[cur_dc_rack->second.dc];
auto& eps = racks[cur_dc_rack->second.rack];
eps.erase(ep);
if (eps.empty()) {
racks.erase(cur_dc_rack->second.rack);
}
_current_locations.erase(cur_dc_rack);
}