Add LWTRetryPolicy: retry CAS timeouts on same host with backoff#783
Draft
mykaul wants to merge 1 commit intoscylladb:masterfrom
Draft
Add LWTRetryPolicy: retry CAS timeouts on same host with backoff#783mykaul wants to merge 1 commit intoscylladb:masterfrom
mykaul wants to merge 1 commit intoscylladb:masterfrom
Conversation
LWT queries use Paxos consensus where the coordinator is the Paxos leader. Retrying on a different host causes Paxos contention — the new coordinator must compete with the original one, potentially causing cascading timeouts. LWTRetryPolicy (extends ExponentialBackoffRetryPolicy) handles this by: - CAS write timeouts: retry on SAME host with exponential backoff - Serial consistency read timeouts: retry on SAME host with backoff - Serial consistency unavailable: retry on NEXT host (paxos quorum lost) - Non-CAS operations: delegate to base ExponentialBackoffRetryPolicy Modeled after gocql's LWTRetryPolicy interface.
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
LWT queries use Paxos consensus where the first replica (Paxos coordinator/leader) drives the consensus rounds. When a CAS write times out, retrying on a different host causes Paxos contention — the new coordinator must compete with the original, potentially causing cascading timeouts across the cluster.
Currently, no built-in retry policy retries CAS write timeouts at all — they are all RETHROWN immediately:
RetryPolicy.on_write_timeout: CAS → RETHROWExponentialBackoffRetryPolicy.on_write_timeout: CAS → RETHROWDowngradingConsistencyRetryPolicy.on_write_timeout: CAS → RETHROWThis PR adds
LWTRetryPolicy, a new retry policy that extendsExponentialBackoffRetryPolicywith LWT-aware behavior:ExponentialBackoffRetryPolicybehaviorThis is modeled after gocql's
LWTRetryPolicyinterface, which retries LWT queries on the same host to avoid Paxos contention. The key comment from gocql (line 188):Usage
Changes
cassandra/policies.py: AddedLWTRetryPolicyclass (extendsExponentialBackoffRetryPolicy)tests/unit/test_policies.py: AddedLWTRetryPolicyTestwith 21 testsTests
21 new tests covering:
All 103 tests in
tests/unit/test_policies.pypass.Related
TokenAwarePolicy): routing to the Paxos leader + retrying on the same host = optimal LWT latency path.