3.x: Route SELECT at SERIAL/LOCAL_SERIAL consistency like LWT#891
Open
nikagra wants to merge 1 commit into
Open
3.x: Route SELECT at SERIAL/LOCAL_SERIAL consistency like LWT#891nikagra wants to merge 1 commit into
nikagra wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Extends LWT load-balancing behavior to non-LWT statements that use SERIAL/LOCAL_SERIAL as their main consistency level, so that they are routed through the Paxos-aware path (e.g. PRESERVE_REPLICA_ORDER) instead of as REGULAR queries. The change touches three load-balancing policies and adds unit + CCM integration coverage.
Changes:
TokenAwarePolicy.getRequestRoutingtreats serial-CL statements as LWT for routing;PreserveReplicaOrderIteratorfilters out remote replicas forLOCAL_SERIAL.LatencyAwarePolicyandRackAwareRoundRobinPolicyextend their existingisLWT()bypasses to cover serial-CL statements via a duplicatedhasSerialConsistencyhelper.- New unit tests across the three policies and a new
LWTLoadBalancingITCCM integration test.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| driver-core/src/main/java/com/datastax/driver/core/policies/TokenAwarePolicy.java | Route serial-CL statements as LWT; restrict to local replicas only for LOCAL_SERIAL. |
| driver-core/src/main/java/com/datastax/driver/core/policies/LatencyAwarePolicy.java | Bypass latency reordering for serial-CL statements. |
| driver-core/src/main/java/com/datastax/driver/core/policies/RackAwareRoundRobinPolicy.java | Skip rack prioritization for serial-CL statements. |
| driver-core/src/test/java/com/datastax/driver/core/policies/TokenAwarePolicyTest.java | New unit tests covering serial routing, LOCAL_SERIAL local-only filtering, and null routing-method fallback. |
| driver-core/src/test/java/com/datastax/driver/core/policies/LatencyAwarePolicyTest.java | New test verifying serial-CL statements are not latency-reordered. |
| driver-core/src/test/java/com/datastax/driver/core/policies/RackAwareRoundRobinPolicyTest.java | New test verifying serial-CL statements skip rack prioritization. |
| driver-core/src/test/java/com/datastax/driver/core/policies/LWTLoadBalancingIT.java | New CCM integration test for SERIAL/LOCAL_SERIAL SELECT routing. |
Fixes: https://scylladb.atlassian.net/browse/DRIVER-616 Statements with SERIAL or LOCAL_SERIAL as their main consistency level should be routed through the LWT path (PRESERVE_REPLICA_ORDER) in the same way as statements where isLWT() returns true. Changes: - TokenAwarePolicy: treat statements with SERIAL/LOCAL_SERIAL consistency as LWT for routing method selection; exclude remote DC replicas from PRESERVE_REPLICA_ORDER plans when consistency is LOCAL_SERIAL - LatencyAwarePolicy: bypass latency-based reordering for SERIAL/LOCAL_SERIAL consistency statements, same as for isLWT() statements - RackAwareRoundRobinPolicy: skip rack prioritization for SERIAL/LOCAL_SERIAL consistency statements, same as for isLWT() statements - Add unit tests in TokenAwarePolicyTest (7 new), LatencyAwarePolicyTest (1), RackAwareRoundRobinPolicyTest (1), and integration test LWTLoadBalancingIT
78c7343 to
115a445
Compare
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.
Note
Fixes DRIVER-616. Related to: #886
Problem
Statements with
SERIALorLOCAL_SERIALset as their main consistency level (viasetConsistencyLevel) are serialised through the Paxos/serial path on the server side — the same path used by LWT writes. However, the 3.x driver only applied LWT load-balancing routing (e.g.PRESERVE_REPLICA_ORDER) to statements whereisLWT()returnedtrue, which is driven exclusively by Scylla's server-side prepare metadata.A normal
SELECTprepared or executed withLOCAL_SERIALconsistency:was routed as
REGULAR, ignoring the configured LWT routing method entirely.Changes
TokenAwarePolicy:getRequestRouting()now treats statements withSERIALorLOCAL_SERIALmain consistency as LWT for routing method selection (same asisLWT()). InPreserveReplicaOrderIterator, remote-DC replicas are excluded when the consistency isLOCAL_SERIAL(preserving local-DC semantics).LatencyAwarePolicy: The latency-reordering bypass that already applied toisLWT()statements is extended to coverSERIAL/LOCAL_SERIALconsistency statements.RackAwareRoundRobinPolicy: The rack-prioritization bypass already in place forisLWT()is extended to coverSERIAL/LOCAL_SERIALconsistency statements.What is NOT changed
setSerialConsistencyLevel()(the paxos-phase serial CL option on LWT writes) is intentionally not affected — only the mainsetConsistencyLevel()triggers LWT routing.isLWT()semantics are unchanged; this is purely additive.Tests
TokenAwarePolicyTest: 7 new unit tests — serial consistency routed as LWT,LOCAL_SERIALexcludes remote replicas, plainSERIALkeeps remote replicas, serial-CL-option does not trigger LWT routing, null routing-method falls back to regular.LatencyAwarePolicyTest: 1 new unit test — serial consistency statements bypass latency reordering.RackAwareRoundRobinPolicyTest: 1 new unit test — serial consistency statements skip rack prioritization.LWTLoadBalancingIT: New CCM integration test — prepares aSimpleStatementwithLOCAL_SERIAL/SERIALconsistency, binds and executes it, verifies coordinator is non-null.All 67 unit tests pass (
mvn test -pl driver-core -Dgroups=unit).