Skip to content

Commit e44785d

Browse files
committed
_refresh_node_list_and_token_map: bring back multiple endpoint check
`test_address_translator_basic` start failing, it maps multiple nodes into the same address, and recent changes to host metadata to be saved based on host_id were breaking this assumption that host with identical endpoint would be filtered out. no sure how real life case is it, but keeping behavier never the less.
1 parent 26832c8 commit e44785d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cassandra/cluster.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3818,6 +3818,8 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
38183818
token_map = {}
38193819

38203820
found_host_ids = set()
3821+
found_endpoints = set()
3822+
38213823
if local_result.parsed_rows:
38223824
local_rows = dict_factory(local_result.column_names, local_result.parsed_rows)
38233825
local_row = local_rows[0]
@@ -3836,7 +3838,10 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
38363838
if new_endpoint.address:
38373839
host.endpoint = new_endpoint
38383840
host.host_id = local_row.get("host_id")
3841+
38393842
found_host_ids.add(host.host_id)
3843+
found_endpoints.add(host.endpoint)
3844+
38403845
host.listen_address = local_row.get("listen_address")
38413846
host.listen_port = local_row.get("listen_port")
38423847
host.broadcast_address = _NodeInfo.get_broadcast_address(local_row)
@@ -3891,12 +3896,16 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
38913896
endpoint = self._cluster.endpoint_factory.create(row)
38923897
host_id = row.get("host_id")
38933898

3899+
if endpoint in found_endpoints:
3900+
log.warning("Found multiple hosts with the same endpoint(%s). Excluding peer %s - %s", endpoint, row.get("peer"), host_id)
3901+
continue
3902+
38943903
if host_id in found_host_ids:
38953904
log.warning("Found multiple hosts with the same host_id (%s). Excluding peer %s", host_id, row.get("peer"))
38963905
continue
38973906

38983907
found_host_ids.add(host_id)
3899-
3908+
found_endpoints.add(endpoint)
39003909
host = self._cluster.metadata.get_host(endpoint)
39013910
datacenter = row.get("data_center")
39023911
rack = row.get("rack")

0 commit comments

Comments
 (0)