{"record":{"id":"3d1d94c3e3bc4596","repo":"apache/cassandra","slug":"caswriteunknownresultexception-consistencylevel-s","errorCode":null,"errorMessage":"CasWriteUnknownResultException(consistencyLevel=%s, acceptCount=%s, requiredParticipants=%s)","messagePattern":"CasWriteUnknownResultException\\(consistencyLevel=(.+?), acceptCount=(.+?), requiredParticipants=(.+?)\\)","errorType":"exception","errorClass":"CasWriteUnknownResultException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageProxy.java","lineNumber":869,"sourceCode":"                    }\n                    catch (Exception ex)\n                    {\n                        logger.error(\"Failed paxos propose locally\", ex);\n                    }\n                });\n            }\n            else\n            {\n                MessagingService.instance().sendWithCallback(message, replica.endpoint(), callback);\n            }\n        }\n        callback.await();\n\n        if (callback.isSuccessful())\n            return true;\n\n        if (backoffIfPartial && !callback.isFullyRefused())\n            throw new CasWriteUnknownResultException(replicaPlan.consistencyLevel(), callback.getAcceptCount(), replicaPlan.requiredParticipants());\n\n        return false;\n    }\n\n    private static void commitPaxos(Commit proposal, ConsistencyLevel consistencyLevel, boolean allowHints, Dispatcher.RequestTime requestTime) throws WriteTimeoutException\n    {\n        boolean shouldBlock = consistencyLevel != ConsistencyLevel.ANY;\n        Keyspace keyspace = Keyspace.open(proposal.update.metadata().keyspace);\n\n        Token tk = proposal.update.partitionKey().getToken();\n\n        AbstractWriteResponseHandler<Commit> responseHandler = null;\n        // NOTE: this ReplicaPlan is a lie, this usage of ReplicaPlan could do with being clarified - the selected() collection is essentially (I think) never used\n        ReplicaPlan.ForWrite replicaPlan = ReplicaPlans.forWrite(keyspace, consistencyLevel, tk, ReplicaPlans.writeAll);\n        if (shouldBlock)\n        {\n            AbstractReplicationStrategy rs = replicaPlan.replicationStrategy();\n            responseHandler = rs.getWriteResponseHandler(replicaPlan, null, WriteType.SIMPLE, proposal::makeMutation, requestTime);","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageProxy.java#L851-L887","documentation":"proposePaxos throws CasWriteUnknownResultException when the Paxos accept phase ended with neither success nor full refusal — some replicas accepted, but quorum was not reached and not all refused. The outcome of the proposal is therefore indeterminate, and Cassandra surfaces consistencyLevel, acceptCount and requiredParticipants so the client knows the result is unknown.","triggerScenarios":"A CAS (LWT) whose Paxos propose/accept round got partial acknowledgments within the timeout, with backoffIfPartial enabled: callback.isSuccessful() is false and callback.isFullyRefused() is false.","commonSituations":"Replica flakiness (partial acks then timeout); network partition affecting a minority of replicas; write timeouts mid-accept. The client cannot tell if the LWT committed.","solutions":["Re-read the row with the same SERIAL/QUORUM consistency to determine whether the CAS actually applied before retrying.","Retry the LWT after checking current state; do not blind-retry conditional logic that is not idempotent.","Increase write_request_timeout_in_ms to reduce partial-ack windows.","Restore full replica connectivity/health to avoid partial quorums."],"exampleFix":"// before: blind retry\ntry { casDebit(acct, 10); } catch (CasWriteUnknownResultException e) { casDebit(acct, 10); }\n// after: check outcome first\ntry { casDebit(acct, 10); }\ncatch (CasWriteUnknownResultException e) {\n    Row r = session.execute(serialSelectBalance(acct)).one();\n    if (r.getInt(\"balance\") >= 10) casDebit(acct, 10);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ResultSet rs = session.execute(lwt);\n    return rs.wasApplied();\n} catch (CasWriteUnknownResultException e) {\n    // outcome indeterminate: verify state at SERIAL before deciding\n    Row cur = session.execute(selectAtSerial(key)).one();\n    return decideFromCurrentState(cur);\n}","preventionTips":["Never blind-retry non-idempotent LWTs after an unknown result.","Keep write_request_timeout_in_ms generous to shrink partial-ack windows.","Monitor replica flakiness that produces partial quorums."],"tags":["paxos","lightweight-transactions","indeterminate-result","timeout"],"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"}