apache/cassandra · error · ConfigurationException

counter_cache_size option was set incorrectly to '<value>',

Error message

counter_cache_size option was set incorrectly to '<value>', supported values are <integer> >= 0.

What it means

counter_cache_size must be a non-negative integer (MiB) or 'auto'. If the parsed value is negative or unparseable, applySimpleConfig deliberately throws NumberFormatException and converts it to ConfigurationException with the standard 'supported values are <integer> >= 0' message.

Source

Thrown at src/java/org/apache/cassandra/config/DatabaseDescriptor.java:1028

        catch (NumberFormatException e)
        {
            throw new ConfigurationException("key_cache_size option was set incorrectly to '"
                                             + (conf.key_cache_size != null ? conf.key_cache_size.toString() : null) + "', supported values are <integer> >= 0.", false);
        }

        try
        {
            // if counter_cache_size option was set to "auto" then size of the cache should be "min(2.5% of Heap (in MiB), 50MiB)
            counterCacheSizeInMiB = (conf.counter_cache_size == null)
                                    ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.025 / 1024 / 1024)), 50)
                                    : conf.counter_cache_size.toMebibytes();

            if (counterCacheSizeInMiB < 0)
                throw new NumberFormatException(); // to escape duplicating error message
        }
        catch (NumberFormatException e)
        {
            throw new ConfigurationException("counter_cache_size option was set incorrectly to '"
                                             + (conf.counter_cache_size != null ? conf.counter_cache_size.toString() : null) + "', supported values are <integer> >= 0.", false);
        }

        try
        {
            // if paxosCacheSizeInMiB option was set to "auto" then size of the cache should be "min(1% of Heap (in MB), 50MB)
            paxosCacheSizeInMiB = (conf.paxos_cache_size == null)
                                  ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.01 / 1024 / 1024)), 50)
                                  : conf.paxos_cache_size.toMebibytes();

            if (paxosCacheSizeInMiB < 0)
                throw new NumberFormatException(); // to escape duplicating error message
        }
        catch (NumberFormatException e)
        {
            throw new ConfigurationException("paxos_cache_size option was set incorrectly to '"
                                             + conf.paxos_cache_size + "', supported values are <integer> >= 0.", false);
        }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set counter_cache_size to a plain non-negative integer of MiB, e.g. 50
  2. Use 'auto' for min(2.5% of heap, 50MiB)
  3. Remove the key to accept the default
  4. Restart the node

Example fix

// before (cassandra.yaml)
counter_cache_size: -1
// after
counter_cache_size: 50
// or
counter_cache_size: auto
Defensive patterns

Strategy: validation

Validate before calling

String v = yaml.get("counter_cache_size");
if (v != null && !v.equals("auto") && Long.parseLong(v) < 0) throw new IllegalArgumentException(v);

Try / catch

try { DatabaseDescriptor.daemonInitialization(); }
catch (ConfigurationException e) { LOG.fatal(e.getMessage()); System.exit(1); }

Prevention

When it happens

Trigger: Node startup with counter_cache_size set to a negative number, a string with units, or any non-integer text in cassandra.yaml.

Common situations: counter_cache_size: -1 to mean unlimited; value like '50M'; accidentally pasted key with a quoted numeric string that the parser rejects.

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/209ce48dc1ef8d60. Report an issue: GitHub.