{"record":{"id":"8e61106e42f012b0","repo":"apache/cassandra","slug":"default-keyspace-rf-to-be-set-d-cannot-be-great","errorCode":null,"errorMessage":"default_keyspace_rf to be set (%d) cannot be greater than maximum_replication_factor_fail_threshold (%d)","messagePattern":"default_keyspace_rf to be set \\((.+?)\\) cannot be greater than maximum_replication_factor_fail_threshold \\((.+?)\\)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":5772,"sourceCode":"    {\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    {\n        if (enabled != conf.use_statements_enabled)\n        {\n            logger.info(\"Setting use_statements_enabled to {}\", enabled);\n            conf.use_statements_enabled = enabled;\n        }","sourceCodeStart":5754,"sourceCodeEnd":5790,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L5754-L5790","documentation":"setDefaultKeyspaceRF enforces the maximum_replication_factor_fail_threshold guardrail: when the max is not disabled (-1), the default RF cannot exceed it. The setter throws IllegalArgumentException naming both values, keeping the default keyspace RF within guardrail policy.","triggerScenarios":"Calling setDefaultKeyspaceRF with a value greater than guardrails.getMaximumReplicationFactorFailThreshold() while that threshold != -1, e.g. setting RF 5 when maximum_replication_factor_fail_threshold is 3.","commonSituations":"Operators raising default RF for larger clusters after guardrails capped it; maximum_replication_factor_fail_threshold set for small clusters then reused in bigger deployments; default RF inherited from a template exceeding the cap.","solutions":["Lower default_keyspace_rf to at most maximum_replication_factor_fail_threshold.","Raise maximum_replication_factor_fail_threshold via guardrails config to accommodate the desired RF.","Set maximum_replication_factor_fail_threshold to -1 (disabled) if no upper cap is wanted."],"exampleFix":"// before\nDatabaseDescriptor.setDefaultKeyspaceRF(5); // max fail threshold is 3\n// after\nGuardrails.setMaximumReplicationFactorFailThreshold(5);\nDatabaseDescriptor.setDefaultKeyspaceRF(5);","handlingStrategy":"validation","validationCode":"int max = DatabaseDescriptor.getGuardrails().getMaximumReplicationFactorFailThreshold(); if (max == -1 || rf <= max) DatabaseDescriptor.setDefaultKeyspaceRF(rf);","typeGuard":"boolean rfWithinMaxGuardrail(int rf) { int max = org.apache.cassandra.db.guardrails.Guardrails.maximumRFFailThreshold(); return max == -1 || rf <= max; }","tryCatchPattern":"try { DatabaseDescriptor.setDefaultKeyspaceRF(rf); } catch (IllegalArgumentException e) { log.error(\"default_keyspace_rf above guardrail max\", e); }","preventionTips":["Check maximum_replication_factor_fail_threshold (or -1 for disabled) before setting default RF.","Raise the guardrail cap when scaling clusters.","Keep default RF and guardrails in one reviewed config change."],"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"}