{"record":{"id":"626efd8c326dbc66","repo":"apache/cassandra","slug":"compaction-tombstone-warning-threshold-needs-to-be","errorCode":null,"errorMessage":"compaction tombstone warning threshold needs to be >= 0, not {count}","messagePattern":"compaction tombstone warning threshold needs to be >= 0, not (.+?)","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":5351,"sourceCode":"        return (int) Converters.KEYSPACE_COUNT_THRESHOLD_TO_GUARDRAIL.unconvert(Guardrails.instance.getKeyspacesWarnThreshold());\n    }\n\n    /** @deprecated See CASSANDRA-17195 */\n    @Deprecated(since = \"4.1\")\n    public void setKeyspaceCountWarnThreshold(int value)\n    {\n        if (value < 0)\n            throw new IllegalStateException(\"Keyspace count warn threshold should be positive, not \"+value);\n        logger.info(\"Changing keyspace count warn threshold from {} to {}\", getKeyspaceCountWarnThreshold(), value);\n        Guardrails.instance.setKeyspacesThreshold((int) Converters.KEYSPACE_COUNT_THRESHOLD_TO_GUARDRAIL.convert(value),\n                                                  Guardrails.instance.getKeyspacesFailThreshold());\n    }\n\n    @Override\n    public void setCompactionTombstoneWarningThreshold(int count)\n    {\n        if (count < 0)\n            throw new IllegalStateException(\"compaction tombstone warning threshold needs to be >= 0, not \"+count);\n        logger.info(\"Setting compaction_tombstone_warning_threshold to {}\", count);\n        Guardrails.instance.setPartitionTombstonesThreshold(count, Guardrails.instance.getPartitionTombstonesFailThreshold());\n    }\n\n    @Override\n    public int getCompactionTombstoneWarningThreshold()\n    {\n        return Math.toIntExact(Guardrails.instance.getPartitionTombstonesWarnThreshold());\n    }\n\n    @Override\n    public boolean getReadThresholdsEnabled()\n    {\n        return DatabaseDescriptor.getReadThresholdsEnabled();\n    }\n\n    @Override\n    public void setReadThresholdsEnabled(boolean value)","sourceCodeStart":5333,"sourceCodeEnd":5369,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L5333-L5369","documentation":"setCompactionTombstoneWarningThreshold() sets the guardrail warning threshold for tombstones per partition during compaction. It throws IllegalStateException when count is negative; a valid non-negative count is forwarded to the Guardrails partition_tombstones warning threshold.","triggerScenarios":"Calling setCompactionTombstoneWarningThreshold(count) with count < 0 via JMX, nodetool, or code.","commonSituations":"Sentinel -1 'unset' values in tuning scripts; operators intending 0 (disable warnings) but passing negative; automated tooling converting percentages to absolute counts incorrectly.","solutions":["Pass a non-negative integer; use 0 to disable the warning threshold.","Clamp with Math.max(0, count) before calling.","Configure compaction_tombstone_warning_threshold in cassandra.yaml instead of runtime tuning."],"exampleFix":"// before\nss.setCompactionTombstoneWarningThreshold(-1); // throws\n// after\nss.setCompactionTombstoneWarningThreshold(Math.max(0, requested)); // 0 disables warnings","handlingStrategy":"validation","validationCode":"if (count < 0) throw new IllegalArgumentException(\"compaction tombstone warn threshold must be >= 0\");\nss.setCompactionTombstoneWarningThreshold(count);","typeGuard":"boolean valid = count >= 0;","tryCatchPattern":"try { ss.setCompactionTombstoneWarningThreshold(c); } catch (IllegalStateException e) { log.warn(\"rejecting negative tombstone threshold {}\", c); }","preventionTips":["Validate count >= 0 before calling.","Use 0 to disable the warning threshold.","Configure compaction_tombstone_warning_threshold in yaml for persistent settings.","Clamp computed values from automation before applying."],"tags":["jmx","guardrails","compaction","validation"],"backgroundTag":"value-out-of-range","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"}