apache/druid · error · IllegalArgumentException

Cannot compare against something that is not a…

Error message

Cannot compare against something that is not a TombstonePartitionedChunk.

What it means

TombstonePartitionedChunk.compareTo returns 0 only when the other chunk is also a TombstonePartitionedChunk; comparing against any other PartitionChunk implementation throws this IllegalArgumentException. Tombstones are equal/ordering-neutral to each other, so cross-type comparison is intentionally unsupported rather than defined.

Solutions

  1. Separate tombstone chunks from regular partition chunks before sorting or comparing them
  2. Guard comparisons with instanceof TombstonePartitionedChunk checks before calling compareTo
  3. Adjust the calling merge/sort logic to treat tombstones as a distinct category instead of relying on Comparable
  4. If a total order over mixed chunks is needed, wrap chunks in a comparator that handles cross types explicitly

Example fix

// before
chunks.sort(Comparator.naturalOrder()); // mixed types throw
// after
chunks.sort((a, b) -> {
  if (a instanceof TombstonePartitionedChunk && b instanceof TombstonePartitionedChunk) return 0;
  if (a instanceof TombstonePartitionedChunk) return -1;
  if (b instanceof TombstonePartitionedChunk) return 1;
  return a.compareTo(b);
});
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(other instanceof TombstonePartitionedChunk)) {
  // handle non-tombstone comparison separately
}

Type guard

static <T> boolean isTombstoneChunk(PartitionChunk<T> c) {
  return c instanceof TombstonePartitionedChunk;
}

Try / catch

try {
  cmp = tombstoneChunk.compareTo(other);
} catch (IllegalArgumentException e) {
  // treat as cross-type: define explicit ordering
}

Prevention

When it happens

Trigger: Calling compareTo or equals on a TombstonePartitionedChunk with a non-tombstone PartitionChunk, e.g. a StringPartitionChunk, typically during timeline chunk sorting or equality checks in segment-drop/replacement code.

Common situations: Segment replacement flows where tombstone chunks and normal chunks end up in the same sorted collection; code iterating a PartitionHolder mixing tombstone and data chunks; tests comparing tombstone chunks to data chunks.

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/b79cacc4aadbab71. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/timeline/partition/TombstonePartitionedChunk.java:74

  @Override
  public boolean isEnd()
  {
    return true;
  }

  @Override
  public int getChunkNumber()
  {
    return 0;
  }

  @Override
  public int compareTo(PartitionChunk<T> other)
  {
    if (other instanceof TombstonePartitionedChunk) {
      return 0;
    } else {
      throw new IllegalArgumentException("Cannot compare against something that is not a TombstonePartitionedChunk.");
    }
  }

  @Override
  @SuppressWarnings("unchecked")
  public boolean equals(Object o)
  {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    return compareTo((TombstonePartitionedChunk<T>) o) == 0;
  }

  @Override

View on GitHub (pinned to 9b90983fd2)