{"record":{"id":"209ce48dc1ef8d60","repo":"apache/cassandra","slug":"counter-cache-size-option-was-set-incorrectly-to","errorCode":null,"errorMessage":"counter_cache_size option was set incorrectly to '<value>', supported values are <integer> >= 0.","messagePattern":"counter_cache_size option was set incorrectly to '<value>', supported values are <integer> >= 0\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":1028,"sourceCode":"        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(\"key_cache_size option was set incorrectly to '\"\n                                             + (conf.key_cache_size != null ? conf.key_cache_size.toString() : null) + \"', supported values are <integer> >= 0.\", false);\n        }\n\n        try\n        {\n            // if counter_cache_size option was set to \"auto\" then size of the cache should be \"min(2.5% of Heap (in MiB), 50MiB)\n            counterCacheSizeInMiB = (conf.counter_cache_size == null)\n                                    ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.025 / 1024 / 1024)), 50)\n                                    : conf.counter_cache_size.toMebibytes();\n\n            if (counterCacheSizeInMiB < 0)\n                throw new NumberFormatException(); // to escape duplicating error message\n        }\n        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(\"counter_cache_size option was set incorrectly to '\"\n                                             + (conf.counter_cache_size != null ? conf.counter_cache_size.toString() : null) + \"', supported values are <integer> >= 0.\", false);\n        }\n\n        try\n        {\n            // if paxosCacheSizeInMiB option was set to \"auto\" then size of the cache should be \"min(1% of Heap (in MB), 50MB)\n            paxosCacheSizeInMiB = (conf.paxos_cache_size == null)\n                                  ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.01 / 1024 / 1024)), 50)\n                                  : conf.paxos_cache_size.toMebibytes();\n\n            if (paxosCacheSizeInMiB < 0)\n                throw new NumberFormatException(); // to escape duplicating error message\n        }\n        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(\"paxos_cache_size option was set incorrectly to '\"\n                                             + conf.paxos_cache_size + \"', supported values are <integer> >= 0.\", false);\n        }","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L1010-L1046","documentation":"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.","triggerScenarios":"Node startup with counter_cache_size set to a negative number, a string with units, or any non-integer text in cassandra.yaml.","commonSituations":"counter_cache_size: -1 to mean unlimited; value like '50M'; accidentally pasted key with a quoted numeric string that the parser rejects.","solutions":["Set counter_cache_size to a plain non-negative integer of MiB, e.g. 50","Use 'auto' for min(2.5% of heap, 50MiB)","Remove the key to accept the default","Restart the node"],"exampleFix":"// before (cassandra.yaml)\ncounter_cache_size: -1\n// after\ncounter_cache_size: 50\n// or\ncounter_cache_size: auto","handlingStrategy":"validation","validationCode":"String v = yaml.get(\"counter_cache_size\");\nif (v != null && !v.equals(\"auto\") && Long.parseLong(v) < 0) throw new IllegalArgumentException(v);","typeGuard":null,"tryCatchPattern":"try { DatabaseDescriptor.daemonInitialization(); }\ncatch (ConfigurationException e) { LOG.fatal(e.getMessage()); System.exit(1); }","preventionTips":["Do not use -1 for unlimited; use 'auto' or a large positive value","Avoid unit suffixes","Review config diffs for stray characters"],"tags":["cassandra","configuration","cache"],"backgroundTag":"invalid-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}