{"record":{"id":"0e6adb71bd292b36","repo":"apache/cassandra","slug":"cannot-achieve-consistency-level-consistencyforco","errorCode":null,"errorMessage":"Cannot achieve consistency level {consistencyForConsensus} {sizeOfConsensusQuorum} > {sizeOfPoll()}","messagePattern":"Cannot achieve consistency level (.+?) (.+?) > (.+?)","errorType":"exception","errorClass":"UnavailableException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/paxos/Paxos.java","lineNumber":507,"sourceCode":"            return get(cfm, key.getToken(), consistency);\n        }\n\n        int sizeOfPoll()\n        {\n            return electorateLive.size();\n        }\n\n        InetAddressAndPort voter(int i)\n        {\n            return electorateLive.endpoint(i);\n        }\n\n        void assureSufficientLiveNodes(boolean isWrite) throws UnavailableException\n        {\n            if (sizeOfConsensusQuorum > sizeOfPoll())\n            {\n                mark(isWrite, m -> m.unavailables, consistencyForConsensus);\n                throw new UnavailableException(\"Cannot achieve consistency level \" + consistencyForConsensus + \" \" + sizeOfConsensusQuorum + \" > \" + sizeOfPoll(), consistencyForConsensus, sizeOfConsensusQuorum, sizeOfPoll());\n            }\n        }\n\n        void assureSufficientLiveNodesForRepair() throws UnavailableException\n        {\n            if (sizeOfConsensusQuorum > sizeOfPoll())\n            {\n                throw UnavailableException.create(consistencyForConsensus, sizeOfConsensusQuorum, sizeOfPoll());\n            }\n        }\n\n        int requiredFor(ConsistencyLevel consistency)\n        {\n            if (consistency == Paxos.nonSerial(consistencyForConsensus))\n                return sizeOfConsensusQuorum;\n\n            return consistency.blockForWrite(replicationStrategy(), pending);\n        }","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/paxos/Paxos.java#L489-L525","documentation":"Before running a Paxos round, Cassandra checks that the number of live replicas able to participate in the poll is at least the required consensus quorum for the requested consistency level (SERIAL/QUORUM-equivalent). If the required quorum exceeds the live poll participants, it throws UnavailableException with this message.","triggerScenarios":"A serial/consensus read or write (LWT or transactional query with SERIAL/LOCAL_SERIAL consistency) attempted while too many replicas of the partition are down/unreachable, so sizeOfPoll() < sizeOfConsensusQuorum for the chosen consistency level.","commonSituations":"Node(s) in the replica set down or being restarted during rolling maintenance; network partitions isolating replicas; RF too low for the requested consistency (e.g. RF=2 with QUORUM needing 2 and one node down); degraded datacenter in a multi-DC setup using SERIAL.","solutions":["Restore availability: bring the down replicas back up or fix network connectivity (nodetool status)","Temporarily reduce the consistency level of the LWT if the application tolerates it (e.g. LOCAL_SERIAL in the correct DC)","Increase replication factor if quorum requirements are routinely too strict for the cluster size","Retry after repair/restart completes; use LOCAL_SERIAL within a healthy DC rather than cross-DC SERIAL"],"exampleFix":"// before\nstmt.setConsistencyLevel(ConsistencyLevel.SERIAL);\n// after (single-DC app)\nstmt.setConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);","handlingStrategy":"retry","validationCode":"// check replica health before issuing serial ops\nboolean healthy = session.execute(\"SELECT * FROM system.local\").one() != null;\n// and run nodetool status externally; require all RF replicas UP for SERIAL keys","typeGuard":null,"tryCatchPattern":"try { session.execute(lwtWithSerial); }\ncatch (UnavailableException e) { /* replicas down: backoff, alert, or downgrade to LOCAL_SERIAL */ }","preventionTips":["Monitor replica availability (nodetool status) before maintenance","Use LOCAL_SERIAL within a single DC to shrink the required quorum","Size RF so quorum tolerates one node down","Avoid serial workloads during rolling restarts"],"tags":["paxos","unavailable","quorum","replica-down"],"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"}