token_metadata: get_endpoint_to_host_id_map_for_reading: restrict to token owners
And verify the they returned host_id isn't null. Call on_internal_error_noexcept in that case since all token owners are expected to have their host_id set. Aborting in testing would help fix issues in this area. Fixes scylladb/scylladb#14843 Refs scylladb/scylladb#14793 Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -561,7 +561,15 @@ std::unordered_map<inet_address, host_id> token_metadata_impl::get_endpoint_to_h
|
||||
std::unordered_map<inet_address, host_id> map;
|
||||
map.reserve(nodes.size());
|
||||
for (const auto& [endpoint, node] : nodes) {
|
||||
map[endpoint] = node->host_id();
|
||||
// Restrict to token-owners
|
||||
if (!(node->is_normal() || node->is_leaving())) {
|
||||
continue;
|
||||
}
|
||||
if (const auto& host_id = node->host_id()) {
|
||||
map[endpoint] = host_id;
|
||||
} else {
|
||||
on_internal_error_noexcept(tlogger, fmt::format("get_endpoint_to_host_id_map_for_reading: endpoint {} has null host_id", endpoint));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user