cluster: fix host state pool refresh races#854
Open
dkropachev wants to merge 1 commit intomasterfrom
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses race conditions and missed reconciliation/notification paths during host up/down transitions in cassandra.cluster.Cluster, ensuring control connections and session pools converge correctly even when host-down handling is discounted.
Changes:
- Adjust
Cluster.signal_connection_failure()/Cluster.on_down()so callers can distinguish “down handling executed” vs “conviction policy said down,” enablingControlConnection._signal_error()to reconnect when down handling is discounted. - Prevent
Session.update_created_pools()from scheduling pool creation for hosts currently being processed byCluster.on_up(). - Make the
Cluster.on_up()“no pool futures” path notify listeners and reconcile session pools, matching the async completion behavior. - Add unit tests covering the discounted-down control connection case, the on-up no-future notification/reconciliation case, and the pool-refresh skip during node-up handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cassandra/cluster.py |
Refines host up/down transition semantics, prevents duplicate pool refresh during node-up handling, and ensures listener notification + pool reconciliation in all on-up paths. |
tests/unit/test_control_connection.py |
Adds coverage ensuring defunct control connections reconnect when host-down handling is discounted. |
tests/unit/test_cluster.py |
Adds coverage for on-up notification/reconciliation without pool futures and for skipping update_created_pools() work while node-up handling is in progress. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cluster.signal_connection_failure()report whether down handling actually ran, so defunct control connections reconnect when host-down handling is discountedSession.update_created_pools()pool creation for hosts already being handled byCluster.on_up()Cluster.on_up()path notify listeners and reconcile session pools like the async completion pathCloses #847
Closes #851
Closes #852
Testing
workflow-prepareandworkflow-testpassed, but the overall run failed when repo-ci hit its internal 300s timeout while a build step was still running. Artifact:7707c4d2abc4992ec7b76d3fcfdc50e79369210e6713c10b27ac85272b70a580.