apache/druid · error · IllegalArgumentException

Invalid max row count:

Error message

Invalid max row count: 

What it means

AppendableIndexBuilder.validate throws IllegalArgumentException when maxRowCount is <= 0, prefixing the message with 'Invalid max row count: '. An appendable index must have a positive row capacity; a non-positive value is always a configuration/builder mistake.

Source

Thrown at processing/src/main/java/org/apache/druid/segment/incremental/AppendableIndexBuilder.java:108

    return this;
  }

  public AppendableIndexBuilder setMaxBytesInMemory(final long maxBytesInMemory)
  {
    this.maxBytesInMemory = maxBytesInMemory;
    return this;
  }

  public AppendableIndexBuilder setPreserveExistingMetrics(final boolean preserveExistingMetrics)
  {
    this.preserveExistingMetrics = preserveExistingMetrics;
    return this;
  }

  public void validate()
  {
    if (maxRowCount <= 0) {
      throw new IllegalArgumentException("Invalid max row count: " + maxRowCount);
    }

    if (incrementalIndexSchema == null) {
      throw new IllegalArgumentException("incrementIndexSchema cannot be null");
    }
  }

  public final IncrementalIndex build()
  {
    log.debug("Building appendable index.");
    validate();
    return buildInner();
  }

  protected abstract IncrementalIndex buildInner();
}

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Call .maxRowCount(N) with N > 0 on the builder before build()
  2. If the count comes from config, validate it is positive before constructing the builder
  3. Use existing factory helpers (e.g. IncrementalIndexSchema-based builders) that set sane defaults

Example fix

// before
new IncrementalIndex.Builder().setIncrementalIndexSchema(schema).build(); // maxRowCount unset
// after
new IncrementalIndex.Builder()
    .setIncrementalIndexSchema(schema)
    .maxRowCount(1_000_000)
    .build();
Defensive patterns

Strategy: validation

Validate before calling

if (maxRowCount <= 0) { throw new IllegalArgumentException("maxRowCount must be > 0, got " + maxRowCount); }

Try / catch

try { builder.validate(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Invalid max row count")) { builder.maxRowCount(DEFAULT_MAX_ROWS); } else { throw e; } }

Prevention

When it happens

Trigger: Building an IncrementalIndex via the builder without calling maxRowCount(int), or explicitly setting 0/negative value, before build() invokes validate().

Common situations: Forgetting to set maxRowCount on a custom builder path (default 0); computing a row count from config that resolves to 0; copy-pasting builder code that omits maxRowCount.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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