{"record":{"id":"ea207d9afc351568","repo":"apache/cassandra","slug":"key-cache-size-option-was-set-incorrectly-to-val","errorCode":null,"errorMessage":"key_cache_size option was set incorrectly to '<value>', supported values are <integer> >= 0.","messagePattern":"key_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":1012,"sourceCode":"                                             + (conf.prepared_statements_cache_size != null ? conf.prepared_statements_cache_size.toString() : null) + \"', supported values are <integer> >= 0.\", false);\n        }\n\n        try\n        {\n            // if key_cache_size option was set to \"auto\" then size of the cache should be \"min(5% of Heap (in MiB), 100MiB)\n            keyCacheSizeInMiB = (conf.key_cache_size == null)\n                                ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024)), 100)\n                                : conf.key_cache_size.toMebibytes();\n\n            if (keyCacheSizeInMiB < 0)\n                throw new NumberFormatException(); // to escape duplicating error message\n\n            // we need this assignment for the Settings Virtual Table - CASSANDRA-17734\n            conf.key_cache_size = new DataStorageSpec.LongMebibytesBound(keyCacheSizeInMiB);\n        }\n        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        }","sourceCodeStart":994,"sourceCodeEnd":1030,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L994-L1030","documentation":"key_cache_size must be a non-negative integer (MiB) or 'auto'. When the value cannot be parsed in applySimpleConfig, ConfigurationException is thrown with the configured value and the expected format.","triggerScenarios":"Node startup with key_cache_size in cassandra.yaml that is non-numeric, negative, or uses a unit suffix.","commonSituations":"Unit suffix like '100MB'; negative value intending unlimited; YAML indentation error making the value land on the wrong key and type.","solutions":["Set key_cache_size to a plain non-negative integer of MiB, e.g. 100","Use 'auto' for min(5% of heap, 100MiB)","Remove the key to accept the default","Restart the node"],"exampleFix":"// before (cassandra.yaml)\nkey_cache_size: 100MB\n// after\nkey_cache_size: 100\n// or\nkey_cache_size: auto","handlingStrategy":"validation","validationCode":"String v = yaml.get(\"key_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":["Use bare integer MiB values or 'auto'","Check YAML indentation so values land on the intended keys","Validate config on a dev node before production rollout"],"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"}