apache/druid · error · IllegalArgumentException

segmentRangeThreshold is not a valid ISO 8601 duration, got

Error message

segmentRangeThreshold is not a valid ISO 8601 duration, got [<segmentRangeThresholdString>]

What it means

WeightedQueryLaningStrategy parses the optional segmentRangeThreshold string as a Joda Period and converts it via toStandardDuration(). A malformed ISO 8601 period (IllegalArgumentException) or a non-fixed-length period such as months (UnsupportedOperationException) causes this IllegalArgumentException naming the offending value.

Solutions

  1. Use an explicit fixed-length ISO 8601 duration, e.g. PT5M for five minutes (note the T separating time parts)
  2. Avoid months/years in segmentRangeThreshold; use days or smaller units
  3. Remove segmentRangeThreshold if the default behavior is acceptable
  4. Lint the laning strategy JSON against the Druid configuration schema before deploy

Example fix

// before
{"type":"sql#weighted","segmentRangeThreshold":"5M"}
// after
{"type":"sql#weighted","segmentRangeThreshold":"PT5M"}
Defensive patterns

Strategy: validation

Validate before calling

try { new org.joda.time.Period(segmentRangeThresholdString).toStandardDuration(); } catch (IllegalArgumentException | UnsupportedOperationException e) { /* reject config */ }

Prevention

When it happens

Trigger: Configuring segmentRangeThreshold with invalid syntax (e.g. "5M" intending five minutes instead of five months, or "five minutes") or calendar-dependent units that cannot become a standard duration.

Common situations: Confusing M (months) with PT..M (minutes) in ISO 8601 strings, hand-edited cluster configs, copying thresholds between fields with different format expectations.

Understand the failure class

Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/549579e5c3d68cab. Report an issue: GitHub.

Appendix: source

Thrown at server/src/main/java/org/apache/druid/server/scheduling/WeightedQueryLaningStrategy.java:158

      try {
        parsedDuration = new Period(durationThresholdString).toStandardDuration();
      }
      catch (IllegalArgumentException | UnsupportedOperationException e) {
        throw new IllegalArgumentException(
            "durationThreshold is not a valid ISO 8601 duration, "
            + "got [" + durationThresholdString + "]"
        );
      }
    }
    final Duration parsedSegmentRange;
    if (segmentRangeThresholdString == null) {
      parsedSegmentRange = null;
    } else {
      try {
        parsedSegmentRange = new Period(segmentRangeThresholdString).toStandardDuration();
      }
      catch (IllegalArgumentException | UnsupportedOperationException e) {
        throw new IllegalArgumentException(
            "segmentRangeThreshold is not a valid ISO 8601 duration, "
            + "got [" + segmentRangeThresholdString + "]"
        );
      }
    }

    Preconditions.checkArgument(
        segmentCountThreshold != null || parsedPeriod != null || parsedDuration != null || parsedSegmentRange != null,
        "At least one of periodThreshold, durationThreshold, segmentCountThreshold, or segmentRangeThreshold must be set"
    );
    Preconditions.checkArgument(
        segmentCountThreshold == null || segmentCountThreshold > 0,
        "segmentCountThreshold must be > 0, got [%s]", segmentCountThreshold
    );
    if (parsedDuration != null) {
      Preconditions.checkArgument(parsedDuration.getMillis() > 0, "durationThreshold must be positive, got [%s]", durationThresholdString);
    }
    if (parsedSegmentRange != null) {

View on GitHub (pinned to 9b90983fd2)