Skip to content

pool: log error when failed to connect to shard #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cassandra/pool.py
Original file line number Diff line number Diff line change
@@ -719,12 +719,15 @@ 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, host_conn=self, 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, host_conn=self, 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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reraise the exception here, otherwise it gonna hide all possible failure from the connection creation, and there plently of those.

also I'm not sure how this fixes anything regarding the blocked shard aware port

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't fix the issue mentioned in the comment.

As mentioned in the issue, the log messages are very misleading - they don't suggest that shard-aware port is blocked. The only thing I change here is to log something in case of shard-aware CQL connection failure.

The main issue (ThreadPoolExecutor blocking enqueued tasks) is still there.

raise
else:
conn = self._session.cluster.connection_factory(self.host.endpoint, host_conn=self, on_orphaned_stream_released=self.on_orphaned_stream_released)