apache/cassandra · error · ConfigurationException
must be greater than 1 for
Error message
%d must be greater than 1 for %s
What it means
ConfigurationException thrown when the compaction_window_size option parses as an integer but is less than 1. The window size together with compaction_window_unit defines the duration of each time window, so a value of 0 or negative produces no valid windows and is rejected. Note the message text says 'greater than 1' while the check is actually < 1, so the minimum accepted value is 1.
Solutions
- Set compaction_window_size to a positive integer (e.g. '1' with unit DAYS for daily windows).
- Remove the option to use the default (1 day).
- Fix upstream computation so it clamps window size to >= 1.
Example fix
// before
{'compaction_window_size':'0','compaction_window_unit':'DAYS'}
// after
{'compaction_window_size':'1','compaction_window_unit':'DAYS'} Defensive patterns
Strategy: validation
Validate before calling
int windowSize = Integer.parseInt(opts.getOrDefault("compaction_window_size", "1"));
if (windowSize < 1) throw new IllegalArgumentException("compaction_window_size must be >= 1"); Try / catch
try { schema.alterTable(cql); } catch (ConfigurationException e) { if (e.getMessage().contains("greater than 1")) { /* set a positive window size and retry */ } else throw e; } Prevention
- Clamp computed window sizes to Math.max(1, size) in templates.
- Use the default (1) with DAYS/HOURS to tune duration instead of 0.
- Never set window size to 0 or negative to 'disable' windows — remove TWCS instead.
When it happens
Trigger: CREATE/ALTER TABLE with {'class':'TimeWindowCompactionStrategy','compaction_window_size':'0'} or any negative integer, e.g. '-1'.
Common situations: Template-driven schema generation where a computed window count evaluates to 0; copy-paste errors dropping a digit; users trying to 'disable' windows by setting size 0.
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
- is not valid for
- At most bytes may be in a compaction level; your…
- Cannot set concurrent_validations greater than…
- compaction_throughput: is too large; it should be less than…
- concurrent_compactors should be strictly greater than 0…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/54c357eb0e684482.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java:128
try
{
if (optionValue != null)
if (!validWindowTimeUnits.contains(TimeUnit.valueOf(optionValue)))
throw new ConfigurationException(String.format("%s is not valid for %s", optionValue, COMPACTION_WINDOW_UNIT_KEY));
}
catch (IllegalArgumentException e)
{
throw new ConfigurationException(String.format("%s is not valid for %s", optionValue, COMPACTION_WINDOW_UNIT_KEY), e);
}
optionValue = options.get(COMPACTION_WINDOW_SIZE_KEY);
try
{
int sstableWindowSize = optionValue == null ? DEFAULT_COMPACTION_WINDOW_SIZE : Integer.parseInt(optionValue);
if (sstableWindowSize < 1)
{
throw new ConfigurationException(String.format("%d must be greater than 1 for %s", sstableWindowSize, COMPACTION_WINDOW_SIZE_KEY));
}
}
catch (NumberFormatException e)
{
throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", optionValue, COMPACTION_WINDOW_SIZE_KEY), e);
}
optionValue = options.get(EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY);
try
{
long expiredCheckFrequency = optionValue == null ? DEFAULT_EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS : Long.parseLong(optionValue);
if (expiredCheckFrequency < 0)
{
throw new ConfigurationException(String.format("%s must not be negative, but was %d", EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY, expiredCheckFrequency));
}
}
catch (NumberFormatException e)
{View on GitHub (pinned to 88fd0f6a0e)