{"record":{"id":"6854bbdb89a2d2a0","repo":"apache/cassandra","slug":"commitlog-segment-size-must-be-positive-but-was","errorCode":null,"errorMessage":"commitlog_segment_size must be positive, but was <value>","messagePattern":"commitlog_segment_size must be positive, but was <value>","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":1123,"sourceCode":"\n        // we need this assignment for the Settings virtual table - CASSANDRA-17735\n        conf.index_summary_capacity = new DataStorageSpec.LongMebibytesBound(indexSummaryCapacityInMiB);\n\n        if (conf.user_defined_functions_fail_timeout.toMilliseconds() < conf.user_defined_functions_warn_timeout.toMilliseconds())\n            throw new ConfigurationException(\"user_defined_functions_warn_timeout must less than user_defined_function_fail_timeout\", false);\n\n        if (!conf.allow_insecure_udfs && !conf.user_defined_functions_threads_enabled)\n            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.\");\n\n        if (conf.allow_extra_insecure_udfs)\n            logger.warn(\"Allowing java.lang.System.* access in UDFs is dangerous and not recommended. Set allow_extra_insecure_udfs: false to disable.\");\n\n        if (conf.scripted_user_defined_functions_enabled)\n            throw new ConfigurationException(\"JavaScript user-defined functions were removed in CASSANDRA-18252. \" +\n                                             \"Hooks are planned to be introduced as part of CASSANDRA-17280\");\n\n        if (conf.commitlog_segment_size.toMebibytes() == 0)\n            throw new ConfigurationException(\"commitlog_segment_size must be positive, but was \"\n                                             + conf.commitlog_segment_size.toString(), false);\n        else if (conf.commitlog_segment_size.toMebibytes() >= 2048)\n            throw new ConfigurationException(\"commitlog_segment_size must be smaller than 2048, but was \"\n                                             + conf.commitlog_segment_size.toString(), false);\n\n        if (conf.max_mutation_size == null)\n            conf.max_mutation_size = new DataStorageSpec.IntKibibytesBound(conf.commitlog_segment_size.toKibibytes() / 2);\n        else if (conf.commitlog_segment_size.toKibibytes() < 2 * conf.max_mutation_size.toKibibytes())\n            throw new ConfigurationException(\"commitlog_segment_size must be at least twice the size of max_mutation_size / 1024\", false);\n\n        if (conf.native_transport_max_message_size == null)\n        {\n            conf.native_transport_max_message_size = new DataStorageSpec.LongBytesBound(calculateDefaultNativeTransportMaxMessageSizeInBytes());\n        }\n        else\n        {\n            nativeTransportMaxMessageSizeConfiguredExplicitly = true;\n            long maxCqlMessageSize = conf.native_transport_max_message_size.toBytes();","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L1105-L1141","documentation":"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.","triggerScenarios":"cassandra.yaml has commitlog_segment_size set to '0' or '0MiB'.","commonSituations":"Operators mistakenly using 0 expecting 'auto' sizing; script-generated configs interpolating an empty/zero default.","solutions":["Set commitlog_segment_size to a positive value less than 2048MiB (e.g. 32MiB) or remove the key to use the default.","Restart the node."],"exampleFix":"# before\ncommitlog_segment_size: 0MiB\n# after\ncommitlog_segment_size: 32MiB","handlingStrategy":"validation","validationCode":"Long mib = parseMebibytes(yaml.get(\"commitlog_segment_size\"));\nif (mib != null && mib <= 0)\n    throw new IllegalArgumentException(\"commitlog_segment_size must be > 0\");","typeGuard":"boolean isValidSegmentSize(Object v) {\n    return v == null || (v instanceof Number && ((Number) v).longValue() > 0);\n}","tryCatchPattern":"try {\n    DatabaseDescriptor.applySimpleConfig();\n} catch (ConfigurationException e) {\n    if (e.getMessage().contains(\"commitlog_segment_size must be positive\"))\n        logger.error(\"Set commitlog_segment_size to a positive value < 2048MiB\");\n}","preventionTips":["Don't use 0 to mean 'auto' — remove the key instead","Enforce range 1..2047 MiB in config validation scripts","Keep the default 32MiB unless profiling says otherwise"],"tags":["config","commitlog"],"backgroundTag":"value-out-of-range","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"}