apache/cassandra · error · ConfigurationException

must be larger than 0, but was

Error message

%s must be larger than 0, but was %s

What it means

LeveledCompactionStrategy validates its sstable_size_in_mb option at strategy construction. If the provided value parses as an integer but is less than 1, a ConfigurationException with this message is thrown, preventing the strategy (and typically the table creation/ALTER) from being applied.

Solutions

  1. Set sstable_size_in_mb to a positive integer (commonly 160, the default)
  2. ALTER the table with corrected options: ALTER TABLE ks.t WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':'160'};
  3. Validate option values before applying them in automation that edits schema

Example fix

// before
{'class':'LeveledCompactionStrategy','sstable_size_in_mb':'0'}
// after
{'class':'LeveledCompactionStrategy','sstable_size_in_mb':'160'}
Defensive patterns

Strategy: validation

Validate before calling

int v = Integer.parseInt(opts.getOrDefault("sstable_size_in_mb", "160"));
if (v < 1) throw new IllegalArgumentException("sstable_size_in_mb must be >= 1");

Try / catch

try { execute("ALTER TABLE ks.t WITH compaction = " + opts); }
catch (ConfigurationException e) { /* fix option values reported in message */ }

Prevention

When it happens

Trigger: CREATE/ALTER TABLE ... WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':'0'} (or a negative number), or the option set programmatically via CompactionParams with a non-positive value.

Common situations: Typos in CQL compaction options such as 0 or -1; scripts generating options with an unset variable; copying config from a cluster using a different unit convention.

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


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

Appendix: source

Thrown at src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java:603

            }
        };
    }

    public static Map<String, String> validateOptions(Map<String, String> options) throws ConfigurationException
    {
        Map<String, String> uncheckedOptions = AbstractCompactionStrategy.validateOptions(options);

        int ssSize;
        int fanoutSize;

        // Validate the sstable_size option
        String size = options.containsKey(SSTABLE_SIZE_OPTION) ? options.get(SSTABLE_SIZE_OPTION) : String.valueOf(DEFAULT_MAX_SSTABLE_SIZE_MIB);
        try
        {
            ssSize = Integer.parseInt(size);
            if (ssSize < 1)
            {
                throw new ConfigurationException(String.format("%s must be larger than 0, but was %s", SSTABLE_SIZE_OPTION, ssSize));
            }
        }
        catch (NumberFormatException ex)
        {
            throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", size, SSTABLE_SIZE_OPTION), ex);
        }

        uncheckedOptions.remove(SSTABLE_SIZE_OPTION);

        // Validate the fanout_size option
        String levelFanoutSize = options.containsKey(LEVEL_FANOUT_SIZE_OPTION) ? options.get(LEVEL_FANOUT_SIZE_OPTION) : String.valueOf(DEFAULT_LEVEL_FANOUT_SIZE);
        try
        {
            fanoutSize = Integer.parseInt(levelFanoutSize);
            if (fanoutSize < 1)
            {
                throw new ConfigurationException(String.format("%s must be larger than 0, but was %s", LEVEL_FANOUT_SIZE_OPTION, fanoutSize));
            }

View on GitHub (pinned to 88fd0f6a0e)