apache/cassandra · error · ConfigurationException
min_compress_ratio can either be 0 or greater than or equal
Error message
min_compress_ratio can either be 0 or greater than or equal to 1
What it means
CompressionParams.validate enforces that min_compress_ratio (maxCompressedLength) is either 0 (disabled) or >= 1. A ratio between 0 and 1 exclusive would claim compression below the input size, and one greater than chunkLength is internally inconsistent, so values in (0,1) are invalid.
Source
Thrown at src/java/org/apache/cassandra/schema/CompressionParams.java:472
}
// chunkLength must be a power of 2 because we assume so when
// computing the chunk number from an uncompressed file offset (see
// CompressedRandomAccessReader.decompresseChunk())
public void validate() throws ConfigurationException
{
// if chunk length was not set (chunkLength == null), this is fine, default will be used
if (chunkLength <= 0)
throw new ConfigurationException("Invalid negative or null " + CHUNK_LENGTH_IN_KB);
if ((chunkLength & (chunkLength - 1)) != 0)
throw new ConfigurationException(CHUNK_LENGTH_IN_KB + " must be a power of 2");
if (maxCompressedLength < 0)
throw new ConfigurationException("Invalid negative " + MIN_COMPRESS_RATIO);
if (maxCompressedLength > chunkLength && maxCompressedLength < Integer.MAX_VALUE)
throw new ConfigurationException(MIN_COMPRESS_RATIO + " can either be 0 or greater than or equal to 1");
}
public Map<String, String> asMap()
{
if (!isEnabled())
return Collections.singletonMap(ENABLED, "false");
Map<String, String> options = new HashMap<>(otherOptions);
// Use the one saved in the registry, we don't want to save the name of the service provider compressor here!
options.put(CLASS, sstableCompressor.serializedAs().getName());
options.put(CHUNK_LENGTH_IN_KB, chunkLengthInKB());
if (minCompressRatio != DEFAULT_MIN_COMPRESS_RATIO)
options.put(MIN_COMPRESS_RATIO, String.valueOf(minCompressRatio));
return options;
}
public String chunkLengthInKB()View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Express the ratio as a value >= 1, e.g. 1.25 means compressed size must be at most 1/1.25 of the original
- Use 0 to disable the ratio check entirely
- If you meant 75% compression, write 1.33 (1/0.75) rather than 0.75
Example fix
// before
{'class': 'LZ4Compressor', 'min_compress_ratio': '0.75'}
// after
{'class': 'LZ4Compressor', 'min_compress_ratio': '1.33'} Defensive patterns
Strategy: validation
Validate before calling
if (ratio != 0 && ratio < 1) throw new IllegalArgumentException("min_compress_ratio must be 0 or >= 1, got: " + ratio); Try / catch
try { params.validate(); } catch (ConfigurationException e) { log.error("invalid min_compress_ratio", e); } Prevention
- Remember the ratio is expressed as >= 1 (e.g. 1.25), never a fraction like 0.75
- Convert percentage compression (75%) into its reciprocal ratio (1.33)
- Use 0 to disable the ratio check
When it happens
Trigger: Calling validate (via setCompressionParameters or fromMap) with min_compress_ratio between 0 and 1 (exclusive), or otherwise greater than chunkLength but below Integer.MAX_VALUE.
Common situations: Assuming the ratio is expressed as bytes-per-byte < 1 or entering a percentage like 0.75 intending 75% ratio instead of 1.75.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- The '%s' option must not be empty. To disable compression us
- Invalid negative or null
- chunk_length_in_kb must be a power of 2
- Invalid negative min_compress_ratio
- Invalid value of auto_snapshot_ttl: ${conf.auto_snapshot_ttl
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/0a423699a3eb4241.
Report an issue: GitHub.