From 44c14f3e2b779409d9c73e4cddd32d0c741bc14c Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Sun, 23 Jul 2023 17:50:02 +0300 Subject: [PATCH 1/2] 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 --- locator/token_metadata.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/locator/token_metadata.cc b/locator/token_metadata.cc index 921cca71bd..e1d6ba80f2 100644 --- a/locator/token_metadata.cc +++ b/locator/token_metadata.cc @@ -561,7 +561,15 @@ std::unordered_map token_metadata_impl::get_endpoint_to_h std::unordered_map 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; } From 6e416b8ff23781e22fba61cc243fee53b0586d15 Mon Sep 17 00:00:00 2001 From: Benny Halevy Date: Mon, 21 Aug 2023 09:20:14 +0300 Subject: [PATCH 2/2] api: storage_service: improve description of /storage_service/host_id Signed-off-by: Benny Halevy --- api/api-doc/storage_service.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api-doc/storage_service.json b/api/api-doc/storage_service.json index 76d90a337c..a01a3abbdb 100644 --- a/api/api-doc/storage_service.json +++ b/api/api-doc/storage_service.json @@ -465,7 +465,7 @@ "operations":[ { "method":"GET", - "summary":"Retrieve the mapping of endpoint to host ID", + "summary":"Retrieve the mapping of endpoint to host ID of all nodes that own tokens", "type":"array", "items":{ "type":"mapper"