Skip to content

Commit

Permalink
pool: log error when failed to connect to shard
Browse files Browse the repository at this point in the history
Added an error log when driver fails to connect to specific shard.
  • Loading branch information
muzarski committed Nov 29, 2023
1 parent 1cc6ccc commit d76116d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cassandra/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,14 @@ def _open_connection_to_missing_shard(self, shard_id):
return
shard_aware_endpoint = self._get_shard_aware_endpoint()
log.debug("shard_aware_endpoint=%r", shard_aware_endpoint)

if shard_aware_endpoint:
conn = self._session.cluster.connection_factory(shard_aware_endpoint, on_orphaned_stream_released=self.on_orphaned_stream_released,
shard_id=shard_id,
total_shards=self.host.sharding_info.shards_count)
conn.original_endpoint = self.host.endpoint
try:
conn = self._session.cluster.connection_factory(shard_aware_endpoint, on_orphaned_stream_released=self.on_orphaned_stream_released,
shard_id=shard_id,
total_shards=self.host.sharding_info.shards_count)
conn.original_endpoint = self.host.endpoint
except Exception as exc:
log.error("Failed to open connection to %s, on shard_id=%i: %s", self.host, shard_id, exc)
else:
conn = self._session.cluster.connection_factory(self.host.endpoint, on_orphaned_stream_released=self.on_orphaned_stream_released)

Expand Down

0 comments on commit d76116d

Please sign in to comment.