apache/hadoop · error · MetricsException
Interval should be positive. Value passed is: {}
Error message
Interval should be positive. Value passed is: {} What it means
MetricsRegistry.newQuantiles creates a MutableQuantiles (rolling-window quantile estimator) and requires a positive rollover interval in seconds; interval <= 0 throws MetricsException('Interval should be positive. Value passed is: <n>') before the estimator is built.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsRegistry.java:221
metricsMap.put(info.name(), ret);
return ret;
}
/**
* Create a mutable metric that estimates quantiles of a stream of values
* @param name of the metric
* @param desc metric description
* @param sampleName of the metric (e.g., "Ops")
* @param valueName of the metric (e.g., "Time" or "Latency")
* @param interval rollover interval of estimator in seconds
* @return a new quantile estimator object
* @throws MetricsException if interval is not a positive integer
*/
public synchronized MutableQuantiles newQuantiles(String name, String desc,
String sampleName, String valueName, int interval) {
checkMetricName(name);
if (interval <= 0) {
throw new MetricsException("Interval should be positive. Value passed" +
" is: " + interval);
}
MutableQuantiles ret =
new MutableQuantiles(name, desc, sampleName, valueName, interval);
metricsMap.put(name, ret);
return ret;
}
/**
* Create a mutable inverse metric that estimates inverse quantiles of a stream of values
* @param name of the metric
* @param desc metric description
* @param sampleName of the metric (e.g., "Ops")
* @param valueName of the metric (e.g., "Rate")
* @param interval rollover interval of estimator in seconds
* @return a new inverse quantile estimator object
* @throws MetricsException if interval is not a positive integer
*/View on GitHub (pinned to 2add963021)
Solutions
- Pass a positive rollover interval in seconds (e.g., 60)
- Validate or clamp config-sourced intervals before the call (default to a sane positive value)
- Fix the configuration property that supplies the interval
Example fix
// before
registry.newQuantiles("QueueTime", "Queue time", "Ops", "Time", intervalSecs); // intervalSecs == 0
// after
int intervalSecs = conf.getInt("my.quantile.interval", 60);
registry.newQuantiles("QueueTime", "Queue time", "Ops", "Time", Math.max(1, intervalSecs)); Defensive patterns
Strategy: validation
Validate before calling
if (interval <= 0) {
throw new IllegalArgumentException("quantile interval must be positive, got " + interval);
}
registry.newQuantiles("QueueTime", "Queue time", "Ops", "Time", interval); Prevention
- Default config-sourced intervals to a positive value (e.g., 60 seconds)
- Clamp with Math.max(1, interval) at the boundary
- Add a config sanity check that fails fast on non-positive quantile intervals
When it happens
Trigger: Calling registry.newQuantiles(name, desc, sampleName, valueName, interval) with interval == 0 or negative — typically a config value that was never set and defaulted to 0.
Common situations: Quantile interval wired from a configuration property that is missing (parses to 0); copy-paste from newRate-style calls that take no interval; test code passing 0 as a placeholder.
Related errors
- Metric name '{}' contains illegal whitespace character
- Invalid read parameters: buf.length=%d, off=%d, len=%d
- Invalid start or len parameter
- Illegal option {}
- Not enough arguments: expected {} but got {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/bc0db9d119cf746f.
Report an issue: GitHub.