{"record":{"id":"879511879324ff9b","repo":"apache/cassandra","slug":"default-keyspace-rf-to-be-set-d-cannot-be-less","errorCode":null,"errorMessage":"default_keyspace_rf to be set (%d) cannot be less than minimum_replication_factor_fail_threshold (%d)","messagePattern":"default_keyspace_rf to be set \\((.+?)\\) cannot be less than minimum_replication_factor_fail_threshold \\((.+?)\\)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":5767,"sourceCode":"        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    {\n        return conf.use_statements_enabled;\n    }\n\n    public static void setUseStatementsEnabled(boolean enabled)\n    {","sourceCodeStart":5749,"sourceCodeEnd":5785,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L5749-L5785","documentation":"setDefaultKeyspaceRF also enforces the minimum_replication_factor_fail_threshold guardrail: the default RF cannot be lower than the RF at which guardrails fail operations. This keeps the default keyspace RF consistent with guardrail policy, throwing IllegalArgumentException with both values in the message.","triggerScenarios":"Calling setDefaultKeyspaceRF with a value below guardrails.getMinimumReplicationFactorFailThreshold(), e.g. setting RF 1 while minimum_replication_factor_fail_threshold is 2 (such as in SimpleStrategy single-node setups or dev configs).","commonSituations":"Dev/test clusters where operators lower the fail threshold or raise it after setting default RF; guardrails configured stricter than the default RF in cassandra.yaml; upgrading clusters where guardrails were tightened.","solutions":["Raise default_keyspace_rf to at least minimum_replication_factor_fail_threshold.","Lower minimum_replication_factor_fail_threshold (e.g. via guardrails config or Guardrails.setMinimumReplicationFactorFailThreshold) to be <= the desired default RF.","Align both values in cassandra.yaml so default_keyspace_rf >= minimum_replication_factor_fail_threshold."],"exampleFix":"// before\nDatabaseDescriptor.setDefaultKeyspaceRF(1); // min fail threshold is 3\n// after\nGuardrails.setMinimumReplicationFactorFailThreshold(1);\nDatabaseDescriptor.setDefaultKeyspaceRF(1);","handlingStrategy":"validation","validationCode":"if (rf >= DatabaseDescriptor.getGuardrails().getMinimumReplicationFactorFailThreshold()) DatabaseDescriptor.setDefaultKeyspaceRF(rf);","typeGuard":"boolean rfMeetsMinGuardrail(int rf) { return rf >= org.apache.cassandra.db.guardrails.Guardrails.minimumRFFailThreshold(); }","tryCatchPattern":"try { DatabaseDescriptor.setDefaultKeyspaceRF(rf); } catch (IllegalArgumentException e) { log.error(\"default_keyspace_rf below guardrail min\", e); }","preventionTips":["Check minimum_replication_factor_fail_threshold before setting default RF.","Keep guardrail thresholds and default RF consistent in cassandra.yaml.","Re-validate after tightening guardrails on upgrades."],"tags":["configuration","guardrails","replication"],"backgroundTag":"conflicting-config-options","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"}