Skip to content

response-future: fence stale endpoint pool use#862

Open
dkropachev wants to merge 3 commits intodk/base-response-future-stale-pool-857from
dk/response-future-stale-pool-857
Open

response-future: fence stale endpoint pool use#862
dkropachev wants to merge 3 commits intodk/base-response-future-stale-pool-857from
dk/response-future-stale-pool-857

Conversation

@dkropachev
Copy link
Copy Markdown
Collaborator

Summary

  • keep timeout cleanup tied to the pool originally borrowed by the request
  • reject stale endpoint pool lookup/borrow races before sending a request
  • return the borrowed stream id before returning a connection after a post-borrow endpoint swap

Notes

This is a focused draft split from the host-state/pool race work. The base branch carries prerequisite fencing changes so this PR diff stays scoped to this issue.

Fixes #857

Testing

Not run for this split branch.

@dkropachev dkropachev self-assigned this May 6, 2026
@dkropachev dkropachev marked this pull request as ready for review May 6, 2026 02:42
Comment thread cassandra/cluster.py
Comment on lines +5666 to +5668
if isinstance(host, Host):
with host.lock:
expected_endpoint = host.endpoint
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do you need to be under lock for such simple assignment?

Comment thread cassandra/cluster.py
Comment on lines +5665 to +5682
expected_endpoint = None
if isinstance(host, Host):
with host.lock:
expected_endpoint = host.endpoint
pool = self.session._get_pool_by_host_identity(
host, expected_endpoint=expected_endpoint)
else:
pool = self.session._get_pool_by_host_identity(host)

if pool and expected_endpoint is not None:
with host.lock:
endpoint_changed = not self.session._endpoints_match(
host.endpoint, expected_endpoint)
if endpoint_changed:
self._errors[host] = ConnectionException(
"Host endpoint changed while borrowing connection")
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Waaait, this is PR from one of your branches to another one of your branches. Why?
I wanted to locally check what is _get_pool_by_host_identity because I don't understand the purpose of this change, but there is not such function.

I don't think you need PRs to make changes to your own work in progress. I think I should revisit this PR when it targets master.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, you mention this in cover letter, sorry.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I still don't think there is much point in reviewing those changes before the base changes are understood and merged (or at least approved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants