alibaba/Sentinel · error · IllegalStateException
count() is unavailable if minMax() has been called
Error message
count() is unavailable if minMax() has been called
What it means
StatEntryFuncMinMax implements the min/max strategy (stat type 4): it keeps only two ValueRef slots — running max and running min with reference strings — maintained via lock-free CAS loops. It has no occurrence counter, so count(long) is unsupported and throws IllegalStateException.
Source
Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/StatEntryFunc.java:154
appender.append(lmin.ref);
}
}
@Override
public Object[] getValues() {
ValueRef lmax = max.get();
ValueRef lmin = min.get();
return new Object[] {lmax.value, lmax.ref, lmin.value, lmin.ref};
}
@Override
public int getStatType() {
return 4;
}
@Override
public void count(long count) {
throw new IllegalStateException("count() is unavailable if minMax() has been called");
}
@Override
public void countAndSum(long count, long value) {
throw new IllegalStateException("countAndSum() is unavailable if minMax() has been called");
}
@Override
public void arrayAdd(long... values) {
throw new IllegalStateException("arrayAdd() is unavailable if minMax() has been called");
}
@Override
public void arraySet(long... values) {
throw new IllegalStateException("arraySet() is unavailable if minMax() has been called");
}
@OverrideView on GitHub (pinned to a3f40ba8e9)
Solutions
- Remove the count() call for min/max entries; min/max entries track extremes only.
- If occurrence counts are also needed, maintain a separate count-and-sum entry in the same logger.
- In generic recorders, branch on getStatType() == 4 to skip count() for min/max entries.
Example fix
// before func.count(1); // func is StatEntryFuncMinMax -> throws func.minMax(value, ref); // after func.minMax(value, ref); // counts go to a separate count-and-sum entry countFunc.countAndSum(1, value);
Defensive patterns
Strategy: type-guard
Validate before calling
if (func.getStatType() != 4) { func.count(1); }
func.minMax(value, ref); // always ok on min/max Type guard
boolean isMinMax(StatEntryFunc f) { return f.getStatType() == 4; } Prevention
- When converting a counter metric to min/max, grep for all count() call sites of that entry.
- Keep counts in a dedicated count-and-sum entry.
- Branch shared recorders on getStatType() == 4.
When it happens
Trigger: Calling count(n) on an entry created with the minMax strategy — e.g. a throughput counter call left in place after the metric was converted to min/max tracking, or a generic recorder that always counts and additionally records extremes.
Common situations: Metric migrated from counter to latency min/max without removing old count() call sites. Shared recording helper hard-codes count() plus optional extras. Config-driven type change missed in one module.
Related errors
- minMax() is unavailable if countAndSum() has been called
- countAndSum() is unavailable if minMax() has been called
- arrayAdd() is unavailable if minMax() has been called
- arraySet() is unavailable if minMax() has been called
- batchAdd() is unavailable if minMax() has been called
AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14).
Data as JSON: /api/errors/1ee376ab83205737.
Report an issue: GitHub.