apache/druid · error · IllegalArgumentException

%s is too large

Error message

%s is too large

What it means

DimensionRangePartitionsSpec.resolveMaxRowsPerSegment derives an effective max rows per segment as targetRowsPerSegment + targetRowsPerSegment/2 using Math.addExact. If that addition overflows an int, the target value was absurdly large (near Integer.MAX_VALUE), so it throws IAE '<name> is too large'.

Source

Thrown at processing/src/main/java/org/apache/druid/indexer/partitions/DimensionRangePartitionsSpec.java:95

    Preconditions.checkArgument(
        (target.getValue() == null) != (max.getValue() == null),
        "Exactly one of " + target.getName() + " or " + max.getName() + " must be present"
    );

    this.resolvedMaxRowPerSegment = resolveMaxRowsPerSegment(target, max);
    this.targetRowsPerSegment = target.getValue();
    this.maxRowsPerSegment = max.getValue();
  }

  private static int resolveMaxRowsPerSegment(Property<Integer> targetRows, Property<Integer> maxRows)
  {
    if (targetRows.getValue() != null) {
      Preconditions.checkArgument(targetRows.getValue() > 0, targetRows.getName() + " must be greater than 0");
      try {
        return Math.addExact(targetRows.getValue(), (targetRows.getValue() / 2));
      }
      catch (ArithmeticException e) {
        throw new IllegalArgumentException(targetRows.getName() + " is too large");
      }
    } else {
      Preconditions.checkArgument(maxRows.getValue() > 0, maxRows.getName() + " must be greater than 0");
      return maxRows.getValue();
    }
  }

  @JsonProperty
  @Override
  @Nullable
  public Integer getTargetRowsPerSegment()
  {
    return targetRowsPerSegment;
  }

  @Override
  public SecondaryPartitionType getType()
  {

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Set targetRowsPerSegment to a realistic value (thousands to a few hundred thousand), not hundreds of millions or more.
  2. If you want no target and a hard cap, set maxRowsPerSegment instead and omit targetRowsPerSegment.
  3. Validate the numeric value in your spec generator before writing the task JSON.

Example fix

// before
"partitionsSpec": {"type": "range", "targetRowsPerSegment": 2000000000}
// after
"partitionsSpec": {"type": "range", "targetRowsPerSegment": 3000000}
Defensive patterns

Strategy: validation

Validate before calling

if (targetRowsPerSegment != null && targetRowsPerSegment > Integer.MAX_VALUE / 2) {
  throw new IllegalArgumentException("targetRowsPerSegment is too large");
}

Prevention

When it happens

Trigger: Setting targetRowsPerSegment (or the resolved sum) to a value greater than roughly Integer.MAX_VALUE/2 (about 1,073,741,823) in partitionsSpec config, causing Math.addExact to overflow.

Common situations: Misconfigured ingestion spec where targetRowsPerSegment was pasted as a huge number or in an unintended unit; generated specs computing partition sizes wrongly; typos adding extra digits.

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


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