{"record":{"id":"6df5d6bc200a4e9a","repo":"apache/cassandra","slug":"default-keyspace-rf-cannot-be-less-than-1","errorCode":null,"errorMessage":"default_keyspace_rf cannot be less than 1","messagePattern":"default_keyspace_rf cannot be less than 1","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":5762,"sourceCode":"    }\n\n    public static void setWriteTombstoneWarnThreshold(int threshold)\n    {\n        validateWriteTombstoneThresholdRange(threshold, conf.min_tracked_partition_tombstone_count);\n        logger.info(\"updating write_tombstone_warn_threshold to {}\", threshold);\n        conf.write_tombstone_warn_threshold = threshold;\n    }\n\n    public static int getDefaultKeyspaceRF()\n    {\n        return conf.default_keyspace_rf;\n    }\n\n    public static void setDefaultKeyspaceRF(int value) throws IllegalArgumentException\n    {\n        if (value < 1)\n        {\n            throw new IllegalArgumentException(\"default_keyspace_rf cannot be less than 1\");\n        }\n\n        if (value < guardrails.getMinimumReplicationFactorFailThreshold())\n        {\n            throw new IllegalArgumentException(String.format(\"default_keyspace_rf to be set (%d) cannot be less than minimum_replication_factor_fail_threshold (%d)\", value, guardrails.getMinimumReplicationFactorFailThreshold()));\n        }\n\n        if (guardrails.getMaximumReplicationFactorFailThreshold() != -1 && value > guardrails.getMaximumReplicationFactorFailThreshold())\n        {\n            throw new IllegalArgumentException(String.format(\"default_keyspace_rf to be set (%d) cannot be greater than maximum_replication_factor_fail_threshold (%d)\", value, guardrails.getMaximumReplicationFactorFailThreshold()));\n        }\n\n        conf.default_keyspace_rf = value;\n    }\n\n\n    public static boolean getUseStatementsEnabled()\n    {","sourceCodeStart":5744,"sourceCodeEnd":5780,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L5744-L5780","documentation":"setDefaultKeyspaceRF rejects a default keyspace replication factor below 1. A default RF of 0 (or negative) is meaningless since every new keyspace would be unreadable/unwritable, so the setter throws IllegalArgumentException before any guardrail checks.","triggerScenarios":"Calling DatabaseDescriptor.setDefaultKeyspaceRF(0) or a negative int, via code, JMX, or a default_keyspace_rf value in configuration that is < 1.","commonSituations":"Templated cassandra.yaml files with default_keyspace_rf: 0 as a placeholder; operators confusing RF 0 with 'system-managed'; scripts computing RF from node counts that yield 0.","solutions":["Set default_keyspace_rf to at least 1 (typically 3 for production).","Fix the templating/placeholder value in cassandra.yaml.","Guard script logic so computed RF values are clamped to >= 1 before calling the setter."],"exampleFix":"// before\nDatabaseDescriptor.setDefaultKeyspaceRF(0);\n// after\nDatabaseDescriptor.setDefaultKeyspaceRF(3);","handlingStrategy":"validation","validationCode":"if (rf >= 1) DatabaseDescriptor.setDefaultKeyspaceRF(rf);","typeGuard":"boolean isValidDefaultRF(int rf) { return rf >= 1; }","tryCatchPattern":"try { DatabaseDescriptor.setDefaultKeyspaceRF(rf); } catch (IllegalArgumentException e) { log.error(\"invalid default_keyspace_rf\", e); }","preventionTips":["Use >= 3 for production defaults; never 0 as a placeholder.","Validate templated cassandra.yaml before deploy.","Clamp computed RF values to >= 1."],"tags":["configuration","replication","validation"],"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"}