apache/cassandra · error · ConfigurationException

commitlog_segment_size must be positive, but was

Error message

commitlog_segment_size must be positive, but was <value>

What it means

Thrown when commitlog_segment_size is zero mebibytes. The commit log segment size must be a positive size so segments can hold at least one mutation; a zero value is rejected in applySimpleConfig before commit log initialization.

Solutions

  1. Set commitlog_segment_size to a positive value less than 2048MiB (e.g. 32MiB) or remove the key to use the default.
  2. Restart the node.

Example fix

# before
commitlog_segment_size: 0MiB
# after
commitlog_segment_size: 32MiB
Defensive patterns

Strategy: validation

Validate before calling

Long mib = parseMebibytes(yaml.get("commitlog_segment_size"));
if (mib != null && mib <= 0)
    throw new IllegalArgumentException("commitlog_segment_size must be > 0");

Type guard

boolean isValidSegmentSize(Object v) {
    return v == null || (v instanceof Number && ((Number) v).longValue() > 0);
}

Try / catch

try {
    DatabaseDescriptor.applySimpleConfig();
} catch (ConfigurationException e) {
    if (e.getMessage().contains("commitlog_segment_size must be positive"))
        logger.error("Set commitlog_segment_size to a positive value < 2048MiB");
}

Prevention

When it happens

Trigger: cassandra.yaml has commitlog_segment_size set to '0' or '0MiB'.

Common situations: Operators mistakenly using 0 expecting 'auto' sizing; script-generated configs interpolating an empty/zero default.

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/6854bbdb89a2d2a0. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/config/DatabaseDescriptor.java:1123

        // we need this assignment for the Settings virtual table - CASSANDRA-17735
        conf.index_summary_capacity = new DataStorageSpec.LongMebibytesBound(indexSummaryCapacityInMiB);

        if (conf.user_defined_functions_fail_timeout.toMilliseconds() < conf.user_defined_functions_warn_timeout.toMilliseconds())
            throw new ConfigurationException("user_defined_functions_warn_timeout must less than user_defined_function_fail_timeout", false);

        if (!conf.allow_insecure_udfs && !conf.user_defined_functions_threads_enabled)
            throw new ConfigurationException("To be able to set enable_user_defined_functions_threads: false you need to set allow_insecure_udfs: true - this is an unsafe configuration and is not recommended.");

        if (conf.allow_extra_insecure_udfs)
            logger.warn("Allowing java.lang.System.* access in UDFs is dangerous and not recommended. Set allow_extra_insecure_udfs: false to disable.");

        if (conf.scripted_user_defined_functions_enabled)
            throw new ConfigurationException("JavaScript user-defined functions were removed in CASSANDRA-18252. " +
                                             "Hooks are planned to be introduced as part of CASSANDRA-17280");

        if (conf.commitlog_segment_size.toMebibytes() == 0)
            throw new ConfigurationException("commitlog_segment_size must be positive, but was "
                                             + conf.commitlog_segment_size.toString(), false);
        else if (conf.commitlog_segment_size.toMebibytes() >= 2048)
            throw new ConfigurationException("commitlog_segment_size must be smaller than 2048, but was "
                                             + conf.commitlog_segment_size.toString(), false);

        if (conf.max_mutation_size == null)
            conf.max_mutation_size = new DataStorageSpec.IntKibibytesBound(conf.commitlog_segment_size.toKibibytes() / 2);
        else if (conf.commitlog_segment_size.toKibibytes() < 2 * conf.max_mutation_size.toKibibytes())
            throw new ConfigurationException("commitlog_segment_size must be at least twice the size of max_mutation_size / 1024", false);

        if (conf.native_transport_max_message_size == null)
        {
            conf.native_transport_max_message_size = new DataStorageSpec.LongBytesBound(calculateDefaultNativeTransportMaxMessageSizeInBytes());
        }
        else
        {
            nativeTransportMaxMessageSizeConfiguredExplicitly = true;
            long maxCqlMessageSize = conf.native_transport_max_message_size.toBytes();

View on GitHub (pinned to 88fd0f6a0e)