Fix LWT prepared statement routing failure in PRESERVE_REPLICA_ORDER mode#832
Closed
Copilot wants to merge 5 commits intoscylla-4.xfrom
Closed
Fix LWT prepared statement routing failure in PRESERVE_REPLICA_ORDER mode#832Copilot wants to merge 5 commits intoscylla-4.xfrom
Copilot wants to merge 5 commits intoscylla-4.xfrom
Conversation
…mode Addresses issue #830 where LWT prepared statements fail with "No node was available" error when using PRESERVE_REPLICA_ORDER routing (default in 4.19.0.5). Changes: - Enhanced newQueryPlanPreserveReplicas to include non-replica nodes with proper DC prioritization - Added fallback logic to prevent empty query plans for prepared statements - Implemented routing-key-based consistent rotation for non-replica nodes - Replaced diceRoll1d4() with universal randomNextInt(bound) method - Updated tests to validate new behavior including randomness testing The fix maintains replica order preservation while ensuring query plans always contain nodes, resolving the regression introduced in 4.19.0.5.
Fixes compilation warning treated as error in CI build.
Corrects syntax error in method override signature.
…licy Move newQueryPlanPreserveReplicas, the RequestRoutingMethod enum, LWT routing dispatch, and randomNextInt from DefaultLoadBalancingPolicy to BasicLoadBalancingPolicy so both policies support preserve-replica-order routing for LWT requests. DefaultLoadBalancingPolicy now only overrides newQueryPlanRegular with its rack-aware shuffling and slow replica avoidance logic. Refactor LWT routing tests into an abstract LwtRoutingTestBase that runs against both BasicLoadBalancingPolicy and DefaultLoadBalancingPolicy, fixing pre-existing test failures caused by incorrect maxNodesPerRemoteDc configuration and missing routing token setup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
Copilot
AI
changed the title
[WIP] Fix LWT prepared statement routing failure in PRESERVE_REPLICA_ORDER mode
Fix LWT prepared statement routing failure in PRESERVE_REPLICA_ORDER mode
Mar 6, 2026
1f98936 to
8122539
Compare
Base automatically changed from
fix-lwt-prepared-statement-routing-830
to
scylla-4.x
March 6, 2026 12:03
|
Done in #831 |
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.
LWT queries with
PRESERVE_REPLICA_ORDERrouting (default since 4.19.0.5) returned empty query plans when replica information wasn't available—common for prepared statements before parameter binding—causing "No node was available" errors.Changes
BasicLoadBalancingPolicy.newQueryPlanPreserveReplicas— Rewrote to always produce a complete query plan with proper 4-tier node prioritization:Moved LWT routing logic up from
DefaultLoadBalancingPolicytoBasicLoadBalancingPolicy—RequestRoutingMethodenum,getRequestRoutingMethod(), andnewQueryPlanPreserveReplicasnow live in the base class so both policy implementations get correct LWT routing.Replaced
diceRoll1d4()withrandomNextInt(int bound)— General-purpose, easier to mock in tests.Extracted
LwtRoutingTestBase— Shared test base forBasicLoadBalancingPolicyLwtRoutingTestandDefaultLoadBalancingPolicyLwtRoutingTest, covering empty replicas fallback, DC prioritization, consistent rotation with routing key, and controlled randomness via Mockito spy.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.