{"record":{"id":"352e682c245c03ad","repo":"apache/cassandra","slug":"timed-out-while-trying-to-cas","errorCode":null,"errorMessage":"Timed out while trying to CAS","messagePattern":"Timed out while trying to CAS","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/schema/DistributedMetadataLogKeyspace.java","lineNumber":110,"sourceCode":"                                                             FIRST.getEpoch(),\n                                                             Transformation.Kind.PRE_INITIALIZE_CMS.toVersionedBytes(preInit),\n                                                             Transformation.Kind.PRE_INITIALIZE_CMS.id,\n                                                             Entry.Id.NONE.entryId);\n\n            UntypedResultSet.Row row = result.one();\n            if (row.getBoolean(\"[applied]\"))\n                return true;\n\n            if (row.getLong(\"epoch\") == FIRST.getEpoch() &&\n                row.getLong(\"entry_id\") == Entry.Id.NONE.entryId &&\n                Transformation.Kind.PRE_INITIALIZE_CMS.id == row.getInt(\"kind\"))\n                return true;\n\n            throw new IllegalStateException(\"Could not initialize log.\");\n        }\n        catch (CasWriteTimeoutException t)\n        {\n            logger.warn(\"Timed out while trying to CAS\", t);\n            return false;\n        }\n        catch (Throwable t)\n        {\n            JVMStabilityInspector.inspectThrowable(t);\n            logger.error(\"Caught an exception while trying to CAS\", t);\n            return false;\n        }\n    }\n\n    public static boolean tryCommit(Entry.Id entryId,\n                                    Transformation transform,\n                                    Epoch previousEpoch,\n                                    Epoch nextEpoch)\n    {\n        try\n        {\n            // log is not initialized yet this is unexpected","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/DistributedMetadataLogKeyspace.java#L92-L128","documentation":"A warn log in DistributedMetadataLogKeyspace.insertPreInitialize when the compare-and-set (CAS) used to initialize the metadata log times out (CasWriteTimeoutException). The method returns false, meaning initialization was not confirmed; the caller typically retries or throws IllegalStateException('Could not initialize log.').","triggerScenarios":"CAS write to the metadata log keyspace times out at the requested consistency level during node startup / log pre-initialization — typically because a quorum of replicas is unavailable or slow.","commonSituations":"Starting a node when other replicas are down or unreachable; cluster-wide load or GC pauses delaying the CAS; misconfigured write request timeout too low for the environment.","solutions":["Ensure a quorum of nodes (including the metadata log replicas) is up and reachable, then retry startup/initialization","Increase cassandra.write_request_timeout_in_ms if CAS writes legitimately take longer","Check system logs on the replicas of the metadata log keyspace for GC pauses or dropped messages","Inspect nodetool status and repair networking/MTU issues causing slow cross-node writes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before init CAS, check quorum availability\nif (!RangeCommands.sufficientLiveNodesForSelectStar(logTable, ConsistencyLevel.QUORUM))\n    throw new IllegalStateException(\"Not enough live nodes to initialize metadata log\");","typeGuard":null,"tryCatchPattern":"try { initialized = insertPreInitialize(...); }\ncatch (CasWriteTimeoutException e) {\n    logger.warn(\"Metadata log init CAS timed out; will retry\", e);\n    // retry after replicas recover\n}","preventionTips":["Keep a quorum of nodes up during startup/schema operations","Tune write_request_timeout_in_ms appropriately","Monitor GC pauses and disk latency on metadata log replicas"],"tags":["cas","schema","timeout","startup"],"backgroundTag":"cas-write-timeout","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}