{"record":{"id":"965ed22a581a119f","repo":"apache/cassandra","slug":"writetimeoutexception","errorCode":null,"errorMessage":"WriteTimeoutException","messagePattern":"WriteTimeoutException","errorType":"exception","errorClass":"WriteTimeoutException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/paxos/v1/AbstractPaxosCallback.java","lineNumber":61,"sourceCode":"        this.consistency = consistency;\n        latch = newCountDownLatch(targets);\n        this.requestTime = requestTime;\n    }\n\n    public int getResponseCount()\n    {\n        return targets - latch.count();\n    }\n\n    public void await() throws WriteTimeoutException\n    {\n        try\n        {\n            long now = Clock.Global.nanoTime();\n            long timeout = requestTime.computeTimeout(now, DatabaseDescriptor.getWriteRpcTimeout(NANOSECONDS));\n\n            if (!latch.await(timeout, NANOSECONDS))\n                throw new WriteTimeoutException(WriteType.CAS, consistency, getResponseCount(), targets);\n        }\n        catch (InterruptedException e)\n        {\n            throw new UncheckedInterruptedException(e);\n        }\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/paxos/v1/AbstractPaxosCallback.java#L43-L69","documentation":"AbstractPaxosCallback.await blocks until enough CAS responses arrive; if the latch times out within DatabaseDescriptor.getWriteRpcTimeout, it throws WriteTimeoutException(WriteType.CAS) reporting achieved vs required responses. This means not enough paxos replicas replied to the CAS write in time.","triggerScenarios":"CAS (INSERT ... IF NOT EXISTS / UPDATE ... IF conditions) at a consistency level whose required replica count did not respond within write_rpc_timeout; slow replicas, GC pauses, or down/unreachable replicas.","commonSituations":"Lightweight transactions under heavy load, one or more replicas down while using QUORUM/SERIAL, network issues in a multi-DC setup, or paxos contention causing slow rounds.","solutions":["Check that enough replicas for the chosen CL are up and responsive (nodetool status)","Increase write_rpc_timeout in cassandra.yaml if paxos rounds are legitimately slow under load","Retry the CAS operation; paxos timeouts are often transient under contention","Reduce LTX contention (fewer contending clients per row) or investigate slow replicas via tracing"],"exampleFix":"// before\ncassandra.yaml: write_rpc_timeout: 2000\n// after\ncassandra.yaml: write_rpc_timeout: 10000\n$ nodetool reloadseeds && restart node (config change requires restart)","handlingStrategy":"retry","validationCode":"// check quorum availability before issuing a CAS\nint alive = replicasFor(key).stream().filter(fd::isAlive).count();\nif (alive < requiredFor(consistencyLevel)) throw new UnavailableException(consistencyLevel, requiredFor(consistencyLevel), alive);","typeGuard":null,"tryCatchPattern":"try { session.execute(casStatement); }\ncatch (WriteTimeoutException e) { if (e.writeType() == WriteType.CAS) { backoff(); retryOnce(); } else throw e; }","preventionTips":["Keep all replicas for hot LWT keys up and healthy","Size write_rpc_timeout to observed paxos round latency","Reduce write contention on the same partition key","Monitor GC pauses on replicas"],"tags":["timeout","paxos","lwt"],"backgroundTag":"request-timeout","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}