pool: fix inverted cooldown check in _get_shard_aware_endpoint#823
Merged
sylwiaszunejko merged 1 commit intoscylladb:masterfrom Apr 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes shard-aware endpoint selection in HostConnection._get_shard_aware_endpoint by correcting the cooldown comparison so advanced shard-awareness is suppressed only during the NAT-detection cooldown window and automatically restored after expiry. Adds/extends unit coverage to exercise the cooldown and hard-disable behavior.
Changes:
- Fix inverted cooldown guard in
HostConnection._get_shard_aware_endpoint(<→>). - Refactor
MockSessiontest helper to module scope for reuse. - Add
test_advanced_shard_aware_cooldownto cover active cooldown, expired cooldown, and hard-disable paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cassandra/pool.py |
Corrects cooldown logic gating shard-aware endpoint selection. |
tests/unit/test_shard_aware.py |
Refactors test scaffolding and adds coverage for cooldown + hard-disable behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The `block_until < time.time()` condition was true only *after* the NAT-detection cooldown had already expired, so the shard-aware port was never suppressed during the 10-minute window and was permanently disabled once that window closed. Fix: flip to `>` so the guard fires while the deadline is in the future. Add unit test covering the active-block, expired-block, and hard-disable paths to prevent regression.
2ae051a to
92a5a3a
Compare
|
We should ask AI to look for more areas uncovered by tests... |
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
_get_shard_aware_endpointusedblock_until < time.time()which isTrueonly after the 10-minute NAT-detection cooldown has expired — the exact opposite of the intended guard.<→>so the branch suppresses the shard-aware endpoint while the deadline is in the future, and restores it automatically once the deadline passes.6eaafc3f(Jul 2020) and undetected because existing tests only covered the happy path.Test plan
python3 -m unittest tests.unit.test_shard_awarepasses (3 tests: existing port test + newtest_advanced_shard_aware_cooldowncovering active-block, expired-block, and hard-disable paths)