{"record":{"id":"ce0e77d3b769b66f","repo":"apache/cassandra","slug":"prepared-statements-cache-size-option-was-set-inco","errorCode":null,"errorMessage":"prepared_statements_cache_size option was set incorrectly to '<value>', supported values are <integer> >= 0.","messagePattern":"prepared_statements_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":993,"sourceCode":"        if (conf.num_tokens != null && conf.num_tokens > MAX_NUM_TOKENS)\n            throw new ConfigurationException(String.format(\"A maximum number of %d tokens per node is supported\", MAX_NUM_TOKENS), false);\n\n        try\n        {\n            // if prepared_statements_cache_size option was set to \"auto\" then size of the cache should be \"max(1/256 of Heap (in MiB), 10MiB)\"\n            preparedStatementsCacheSizeInMiB = (conf.prepared_statements_cache_size == null)\n                                               ? Math.max(10, (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024 / 256))\n                                               : conf.prepared_statements_cache_size.toMebibytes();\n\n            if (preparedStatementsCacheSizeInMiB == 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.prepared_statements_cache_size = new DataStorageSpec.LongMebibytesBound(preparedStatementsCacheSizeInMiB);\n        }\n        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(\"prepared_statements_cache_size option was set incorrectly to '\"\n                                             + (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        {","sourceCodeStart":975,"sourceCodeEnd":1011,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L975-L1011","documentation":"prepared_statements_cache_size must parse as a non-negative integer (MiB) or the special value 'auto'. If parsing to preparedStatementsCacheSizeInMiB fails (NumberFormatException), applySimpleConfig wraps it as ConfigurationException showing the offending value.","triggerScenarios":"Node startup where cassandra.yaml has prepared_statements_cache_size set to a non-numeric string, a negative number, or an unparseable unit form.","commonSituations":"Writing '10MB' or '10 MiB' when a bare integer is expected; quoting issues in YAML; setting -1 intending 'unlimited'; locale-formatted numbers.","solutions":["Set prepared_statements_cache_size to a plain non-negative integer of MiB, e.g. 256","Use the literal value auto to size the cache automatically (max(1/256 of heap, 10MiB))","Remove the key to accept the auto default","Restart the node"],"exampleFix":"// before (cassandra.yaml)\nprepared_statements_cache_size: 10MB\n// after\nprepared_statements_cache_size: 256\n// or\nprepared_statements_cache_size: auto","handlingStrategy":"validation","validationCode":"// value must be a bare non-negative integer (MiB) or the literal 'auto'\nString v = yaml.get(\"prepared_statements_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":["Never append unit suffixes to cache size options","Use 'auto' when unsure","Keep cache sizes as integers in MiB in config templates"],"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"}