{"record":{"id":"c50d5021c86070c2","repo":"apache/cassandra","slug":"invalid-value-for-segment-write-buffer-size-value","errorCode":null,"errorMessage":"Invalid value for segment_write_buffer_size. Value must be a positive integer less than 32768MiB","messagePattern":"Invalid value for segment_write_buffer_size\\. Value must be a positive integer less than 32768MiB","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/StorageAttachedIndexOptions.java","lineNumber":43,"sourceCode":"{\n    public static final int DEFAULT_SEGMENT_BUFFER_MB = 1024;\n\n    @VisibleForTesting\n    public static final int MAXIMUM_SEGMENT_BUFFER_MB = 32768;\n\n    @VisibleForTesting\n    public static final String INVALID_BUFFER_SIZE_ERROR = \"Invalid value for segment_write_buffer_size. \" +\n                                                           \"Value must be a positive integer less than \" + MAXIMUM_SEGMENT_BUFFER_MB + \"MiB\";\n\n    public DataStorageSpec.IntMebibytesBound segment_write_buffer_size = new DataStorageSpec.IntMebibytesBound(DEFAULT_SEGMENT_BUFFER_MB);\n    \n    public volatile boolean prioritize_over_legacy_index = false;\n\n    public void validate()\n    {\n        if (segment_write_buffer_size.toMebibytes() > MAXIMUM_SEGMENT_BUFFER_MB)\n        {\n            throw new ConfigurationException(INVALID_BUFFER_SIZE_ERROR);\n        }\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":47,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/StorageAttachedIndexOptions.java#L25-L47","documentation":"StorageAttachedIndexOptions.validate() enforces that segment_write_buffer_size does not exceed MAXIMUM_SEGMENT_BUFFER_MB (32768 MiB) for storage-attached indexes, throwing ConfigurationException otherwise. It guards against allocating an unreasonably large SAI segment write buffer.","triggerScenarios":"Setting segment_write_buffer_size in cassandra.yaml (or via a Config object) to a value above 32768MiB, then triggering validation at startup or config load.","commonSituations":"Very large buffers configured hoping to speed up SAI builds; unit mistakes (GiB vs MiB) producing oversized values; copied configs from environments with different limits.","solutions":["Lower segment_write_buffer_size to at most 32768MiB","Express the value with explicit units, e.g. 512MiB, to avoid unit confusion","Leave the default if unsure"],"exampleFix":"# before\nsegment_write_buffer_size: 64GiB\n# after\nsegment_write_buffer_size: 512MiB","handlingStrategy":"validation","validationCode":"if (config.storage_attached_indexes != null\n    && config.storage_attached_indexes.segment_write_buffer_size.toMebibytes() > 32768)\n    throw new IllegalArgumentException(\"segment_write_buffer_size must be <= 32768MiB\");","typeGuard":"static boolean isValidSegmentBuffer(DataStorage.LongBytesProp v) {\n    return v != null && v.toMebibytes() <= 32768;\n}","tryCatchPattern":"try { saiOptions.validate(); }\ncatch (ConfigurationException e) { log.error(\"Fix segment_write_buffer_size: {}\", e.getMessage()); throw e; }","preventionTips":["Write sizes with explicit units (e.g. 512MiB) to avoid unit confusion","Keep buffer sizes within documented maximums","Validate configs with cassandra config tooling before rollout"],"tags":["configuration","sai","validation","memory"],"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"}