apache/cassandra · warning

Timed out while trying to CAS

Error message

Timed out while trying to CAS

What it means

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.').

Solutions

  1. Ensure a quorum of nodes (including the metadata log replicas) is up and reachable, then retry startup/initialization
  2. Increase cassandra.write_request_timeout_in_ms if CAS writes legitimately take longer
  3. Check system logs on the replicas of the metadata log keyspace for GC pauses or dropped messages
  4. Inspect nodetool status and repair networking/MTU issues causing slow cross-node writes
Defensive patterns

Strategy: retry

Validate before calling

// before init CAS, check quorum availability
if (!RangeCommands.sufficientLiveNodesForSelectStar(logTable, ConsistencyLevel.QUORUM))
    throw new IllegalStateException("Not enough live nodes to initialize metadata log");

Try / catch

try { initialized = insertPreInitialize(...); }
catch (CasWriteTimeoutException e) {
    logger.warn("Metadata log init CAS timed out; will retry", e);
    // retry after replicas recover
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/352e682c245c03ad. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/schema/DistributedMetadataLogKeyspace.java:110

                                                             FIRST.getEpoch(),
                                                             Transformation.Kind.PRE_INITIALIZE_CMS.toVersionedBytes(preInit),
                                                             Transformation.Kind.PRE_INITIALIZE_CMS.id,
                                                             Entry.Id.NONE.entryId);

            UntypedResultSet.Row row = result.one();
            if (row.getBoolean("[applied]"))
                return true;

            if (row.getLong("epoch") == FIRST.getEpoch() &&
                row.getLong("entry_id") == Entry.Id.NONE.entryId &&
                Transformation.Kind.PRE_INITIALIZE_CMS.id == row.getInt("kind"))
                return true;

            throw new IllegalStateException("Could not initialize log.");
        }
        catch (CasWriteTimeoutException t)
        {
            logger.warn("Timed out while trying to CAS", t);
            return false;
        }
        catch (Throwable t)
        {
            JVMStabilityInspector.inspectThrowable(t);
            logger.error("Caught an exception while trying to CAS", t);
            return false;
        }
    }

    public static boolean tryCommit(Entry.Id entryId,
                                    Transformation transform,
                                    Epoch previousEpoch,
                                    Epoch nextEpoch)
    {
        try
        {
            // log is not initialized yet this is unexpected

View on GitHub (pinned to 88fd0f6a0e)