apache/cassandra · error · IllegalStateException
Table count warn threshold should be positive, not {value}
Error message
Table count warn threshold should be positive, not {value} What it means
setTableCountWarnThreshold() is a deprecated (CASSANDRA-17195, since 4.1) bridge from the old table-count threshold knobs to guardrails. It throws IllegalStateException for values below 0, since a warning threshold of a negative table count is meaningless.
Source
Thrown at src/java/org/apache/cassandra/service/StorageService.java:5323
public void setAutoOptimisePreviewRepairStreams(boolean enabled)
{
DatabaseDescriptor.setAutoOptimisePreviewRepairStreams(enabled);
}
/** @deprecated See CASSANDRA-17195 */
@Deprecated(since = "4.1")
public int getTableCountWarnThreshold()
{
return (int) Converters.TABLE_COUNT_THRESHOLD_TO_GUARDRAIL.unconvert(Guardrails.instance.getTablesWarnThreshold());
}
/** @deprecated See CASSANDRA-17195 */
@Deprecated(since = "4.1")
public void setTableCountWarnThreshold(int value)
{
if (value < 0)
throw new IllegalStateException("Table count warn threshold should be positive, not "+value);
logger.info("Changing table count warn threshold from {} to {}", getTableCountWarnThreshold(), value);
Guardrails.instance.setTablesThreshold((int) Converters.TABLE_COUNT_THRESHOLD_TO_GUARDRAIL.convert(value),
Guardrails.instance.getTablesFailThreshold());
}
/** @deprecated See CASSANDRA-17195 */
@Deprecated(since = "4.1")
public int getKeyspaceCountWarnThreshold()
{
return (int) Converters.KEYSPACE_COUNT_THRESHOLD_TO_GUARDRAIL.unconvert(Guardrails.instance.getKeyspacesWarnThreshold());
}
/** @deprecated See CASSANDRA-17195 */
@Deprecated(since = "4.1")
public void setKeyspaceCountWarnThreshold(int value)
{
if (value < 0)
throw new IllegalStateException("Keyspace count warn threshold should be positive, not "+value);View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a non-negative integer (0 effectively disables the warn threshold).
- Clamp input: Math.max(0, value) before calling.
- Migrate to Guardrails 'tables' configuration directly, since this setter is deprecated.
Example fix
// before ss.setTableCountWarnThreshold(-1); // throws // after ss.setTableCountWarnThreshold(Math.max(0, requested)); // or use guardrails tables warn threshold
Defensive patterns
Strategy: validation
Validate before calling
if (value < 0) throw new IllegalArgumentException("table count warn threshold must be >= 0");
ss.setTableCountWarnThreshold(value); Type guard
boolean valid = value >= 0;
Try / catch
try { ss.setTableCountWarnThreshold(v); } catch (IllegalStateException e) { log.warn("rejecting negative threshold {}", v); } Prevention
- Reject/clamp negative values at the script boundary.
- Replace -1 'unset' sentinels with 0.
- Prefer the guardrails 'tables' configuration over this deprecated setter.
- Sanity-check computed thresholds before applying.
When it happens
Trigger: Calling setTableCountWarnThreshold(value) with value < 0 via JMX, nodetool, or code.
Common situations: Scripts computing thresholds from a percentage or delta and producing negatives; copy-pasted config defaults of -1 meaning 'unset'; migration tooling porting old yaml values.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Keyspace count warn threshold should be positive, not {value
- compaction tombstone warning threshold needs to be >= 0, not
- Invalid guardrails configuration:
- Invalid value %d for %s: negative values are not allowed, ou
- Invalid values for %s: '%s' do not parse as valid %s propert
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3835b497c43c4472.
Report an issue: GitHub.