apache/cassandra · error · ConfigurationException

Compression parameters too long, length

Error message

Compression parameters too long, length %d cannot be above 65535.

What it means

CommitLogDescriptor.writeHeader serializes the segment's compression/encryption parameters as a UTF-8 string, whose length is written as an unsigned short (max 65535 bytes). If the parameters string exceeds that, a ConfigurationException is thrown so the header is never written in a form that could not be read back.

Solutions

  1. Trim the compression/encryption parameter map in cassandra.yaml (or the CompressionParams/EncryptionContext built programmatically) to a sane size.
  2. Remove duplicate or obsolete keys from compression_options / encryption_options.
  3. If building descriptors in tests, generate fewer additionalHeaders so the serialized string stays under 65535 bytes.
  4. Shorten long custom parameter values (e.g. long keystore paths or embedded config blobs).

Example fix

// before
Map<String,String> opts = hugeGeneratedOptionMap; // thousands of entries -> ConfigurationException
// after
Map<String,String> opts = Map.of("class_name", "LZ4Compressor", "chunk_length_in_kb", "16");
Defensive patterns

Strategy: validation

Validate before calling

String s = descriptor.parametersAsCreateString(); // or serialize yourself
if (s.getBytes(StandardCharsets.UTF_8).length > 65535)
    throw new IllegalArgumentException("Compression/encryption parameters too long for commit log header");

Try / catch

try (CommitLogSegmentFile f = open(descriptor)) { ... } catch (ConfigurationException e) { logger.error("Header params too large: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Opening a new commit log segment (writeHeader, via writeHeader-fromHeader path) with a descriptor whose combined compression + encryption + additionalHeaders parameters string exceeds 65535 UTF-8 bytes — typically thousands of compression option entries.

Common situations: cassandra.yaml compression or encryption_context options bloated with very large maps (e.g. many chunk_length/iv parameters or an enormous parameter map injected programmatically in tests).

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java:112

    {
        writeHeader(out, descriptor, Collections.<String, String>emptyMap());
    }

    /**
     * @param additionalHeaders Allow segments to pass custom header data
     */
    public static void writeHeader(ByteBuffer out, CommitLogDescriptor descriptor, Map<String, String> additionalHeaders)
    {
        CRC32 crc = new CRC32();
        out.putInt(descriptor.version);
        updateChecksumInt(crc, descriptor.version);
        out.putLong(descriptor.id);
        updateChecksumInt(crc, (int) (descriptor.id & 0xFFFFFFFFL));
        updateChecksumInt(crc, (int) (descriptor.id >>> 32));
        String parametersString = constructParametersString(descriptor.compression, descriptor.encryptionContext, additionalHeaders);
        byte[] parametersBytes = parametersString.getBytes(StandardCharsets.UTF_8);
        if (parametersBytes.length != (((short) parametersBytes.length) & 0xFFFF))
            throw new ConfigurationException(String.format("Compression parameters too long, length %d cannot be above 65535.",
                        parametersBytes.length));
        out.putShort((short) parametersBytes.length);
        updateChecksumInt(crc, parametersBytes.length);
        out.put(parametersBytes);
        crc.update(parametersBytes, 0, parametersBytes.length);
        out.putInt((int) crc.getValue());
    }

    @VisibleForTesting
    static String constructParametersString(ParameterizedClass compression, EncryptionContext encryptionContext, Map<String, String> additionalHeaders)
    {
        Map<String, Object> params = new TreeMap<>();
        if (compression != null)
        {
            params.put(COMPRESSION_PARAMETERS_KEY, compression.parameters);
            params.put(COMPRESSION_CLASS_KEY, compression.class_name);
        }
        if (encryptionContext != null)

View on GitHub (pinned to 88fd0f6a0e)