Skip to content

Commit 1a21378

Browse files
authored
Merge pull request #304 from sylwiaszunejko/fix_resolved_hosts
Only add host if endpoint is not already present
2 parents 8138dca + f2a80f1 commit 1a21378

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cassandra/cluster.py

+3
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,9 @@ def add_host(self, endpoint, datacenter=None, rack=None, signal=True, refresh_no
21692169
the metadata.
21702170
Intended for internal use only.
21712171
"""
2172+
with self.metadata._hosts_lock:
2173+
if endpoint in self.metadata._host_id_by_endpoint:
2174+
return self.metadata._hosts[self.metadata._host_id_by_endpoint[endpoint]], False
21722175
host, new = self.metadata.add_or_return_host(Host(endpoint, self.conviction_policy_factory, datacenter, rack, host_id=host_id))
21732176
if new and signal:
21742177
log.info("New Cassandra host %r discovered", host)

0 commit comments

Comments
 (0)