apache/cassandra · error · CasWriteTimeoutException
CasWriteTimeoutException(writeType=CAS, consistency=%s, rece
Error message
CasWriteTimeoutException(writeType=CAS, consistency=%s, received=%s, blockFor=%s, contentions=%s)
What it means
beginAndRepairPaxos converts a WriteTimeoutException observed while preparing/repairing the Paxos ballot into a CasWriteTimeoutException with writeType=CAS, preserving the original received/blockFor. Per CASSANDRA-8672 the write type is reported as CAS because the failure occurs during Paxos preparation, not a normal write.
Source
Thrown at src/java/org/apache/cassandra/service/StorageProxy.java:776
// mean we lost messages), we pro-actively "repair" those nodes, and retry.
Iterable<InetAddressAndPort> missingMRC = summary.replicasMissingMostRecentCommit(metadata);
if (Iterables.size(missingMRC) > 0)
{
Tracing.trace("Repairing replicas that missed the most recent commit");
sendCommit(mostRecent, consistencyForPaxos, missingMRC);
// TODO: provided commits don't invalid the prepare we just did above (which they don't), we could just wait
// for all the missingMRC to acknowledge this commit and then move on with proposing our value. But that means
// adding the ability to have commitPaxos block, which is exactly CASSANDRA-5442 will do. So once we have that
// latter ticket, we can pass CL.ALL to the commit above and remove the 'continue'.
continue;
}
return new PaxosBallotAndContention(ballot, contentions);
}
catch (WriteTimeoutException e)
{
// We're still doing preparation for the paxos rounds, so we want to use the CAS (see CASSANDRA-8672)
throw new CasWriteTimeoutException(WriteType.CAS, e.consistency, e.received, e.blockFor, contentions);
}
}
throw new CasWriteTimeoutException(WriteType.CAS, consistencyForPaxos, 0, consistencyForPaxos.blockFor(paxosPlan.replicationStrategy()), contentions);
}
/**
* Unlike commitPaxos, this does not wait for replies
*/
private static void sendCommit(Commit commit, ConsistencyLevel consistencyForPaxos, Iterable<InetAddressAndPort> replicas)
{
Message<Commit> message = Message.out(PAXOS_COMMIT_REQ, commit);
for (InetAddressAndPort target : replicas)
MessagingService.instance().send(message, target);
}
private static PrepareCallback preparePaxos(Commit toPrepare, ReplicaPlan.ForPaxosWrite replicaPlan, Dispatcher.RequestTime requestTime)
throws WriteTimeoutExceptionView on GitHub (pinned to 88fd0f6a0e)
Solutions
- Retry the operation; a new coordinator will complete the stale ballot and proceed.
- Increase cas_contention_timeout_in_ms and write_request_timeout_in_ms.
- Investigate replicas with GC pauses or network issues that slow the prepare rounds.
- Reduce LWT concurrency on the partition to avoid repeated ballot contention.
Example fix
// before ConsistencyLevel cl = ConsistencyLevel.SERIAL; // cross-dc LWT, slow prepares // after ConsistencyLevel cl = ConsistencyLevel.LOCAL_SERIAL; // localize paxos rounds
Defensive patterns
Strategy: retry
Try / catch
try {
session.execute(lwt);
} catch (CasWriteTimeoutException e) {
// prepare-phase timeout; safe to retry with a fresh ballot
retryWithBackoff(lwt);
} Prevention
- Ensure crashed coordinators' ballots complete quickly (healthy replicas).
- Tune cas_contention_timeout_in_ms and write_request_timeout_in_ms together.
- Use LOCAL_SERIAL where possible to shorten prepare rounds.
When it happens
Trigger: During a CAS, the initial Paxos prepare/retry loop fails because a replica with a promised in-progress ballot times out on the prepare round; called from the pair()/execute path.
Common situations: A previous LWT coordinator died mid-ballot leaving an in-progress Paxos state that must be completed; slow replicas during the prepare phase; repeated contention increments.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- CasWriteTimeoutException(writeType=%s, consistency=%s, recei
- CasWriteTimeoutException(writeType=CAS, consistency=%s, rece
- CasWriteUnknownResultException(consistencyLevel=%s, acceptCo
- ReadTimeoutException(consistency=%s, received=0, blockFor=%s
- Operation timed out
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/7ac4b184926391d1.
Report an issue: GitHub.