apache/cassandra · critical · IllegalArgumentException

Commit log flush interval must be positive: %fms

Error message

Commit log flush interval must be positive: %fms

What it means

AbstractCommitLogService.start validates the computed commit log sync interval before starting its flush loop. For non-batch commit log services, an interval below 1 nanosecond is invalid, so it throws IllegalArgumentException with the interval in milliseconds. Batch mode is exempt because indefinite waiting is legitimate there.

Source

Thrown at src/java/org/apache/cassandra/db/commitlog/AbstractCommitLogService.java:151

                if (modulo >= markerIntervalMillis / 2)
                    syncIntervalMillis += markerIntervalMillis;
            }
            assert syncIntervalMillis % markerIntervalMillis == 0;
            logger.debug("Will update the commitlog markers every {}ms and flush every {}ms", markerIntervalMillis, syncIntervalMillis);
        }
        else
        {
            markerIntervalMillis = syncIntervalMillis;
        }
        this.markerIntervalNanos = NANOSECONDS.convert(markerIntervalMillis, MILLISECONDS);
        this.syncIntervalNanos = NANOSECONDS.convert(syncIntervalMillis, MILLISECONDS);
    }

    // Separated into individual method to ensure relevant objects are constructed before this is started.
    void start()
    {
        if (syncIntervalNanos < 1 && !(this instanceof BatchCommitLogService)) // permit indefinite waiting with batch, as perfectly sensible
            throw new IllegalArgumentException(String.format("Commit log flush interval must be positive: %fms",
                                                             syncIntervalNanos * 1e-6));

        SyncRunnable sync = new SyncRunnable(preciseTime);
        executor = executorFactory().infiniteLoop(name, sync, SAFE, NON_DAEMON, SYNCHRONIZED);
    }

    class SyncRunnable implements Interruptible.Task
    {
        private final MonotonicClock clock;
        private long firstLagAt = 0;
        private long totalSyncDuration = 0; // total time spent syncing since firstLagAt
        private long syncExceededIntervalBy = 0; // time that syncs exceeded pollInterval since firstLagAt
        private int lagCount = 0;
        private int syncCount = 0;

        SyncRunnable(MonotonicClock clock)
        {
            this.clock = clock;

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set commitlog_sync_period_in_ms in cassandra.yaml to a positive value (default 10000) when using periodic commitlog_sync
  2. If batch durability is wanted, use commitlog_sync: batch instead, where the interval check is not applied
  3. Validate cassandra.yaml values (ant/fill in positive integers) before rolling out config changes

Example fix

// before (cassandra.yaml)
commitlog_sync: periodic
commitlog_sync_period_in_ms: 0
// after
commitlog_sync: periodic
commitlog_sync_period_in_ms: 10000
Defensive patterns

Strategy: validation

Validate before calling

long periodMs = yaml.getLong("commitlog_sync_period_in_ms");
if ("periodic".equals(syncMode) && periodMs < 1)
    throw new IllegalArgumentException("commitlog_sync_period_in_ms must be > 0 for periodic sync");

Type guard

null

Try / catch

try { startCassandra(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Commit log flush interval")) { /* fix cassandra.yaml and restart */ } else throw e; }

Prevention

When it happens

Trigger: Configuring commitlog_sync_period_in_ms (or a derived sync interval) to 0 or a negative value in cassandra.yaml with commitlog_sync periodic (or with group sync), then starting the node.

Common situations: Typo in cassandra.yaml (commitlog_sync_period_in_ms: 0); template-generated configs substituting empty values; copying a batch-mode config to a periodic setup.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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