apache/druid · error · IllegalArgumentException

Task dataSource must match action dataSource, [%s] != [%s].

Error message

Task dataSource must match action dataSource, [%s] != [%s].

What it means

SegmentAllocateAction.perform() enforces that the Task executing this action is allocating a segment for its own datasource. The task's dataSource must equal the action's dataSource field; any mismatch is rejected with this IAE before touching the metadata store. This guards against a task obtaining or poisoning segment lineage for another datasource.

Source

Thrown at indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SegmentAllocateAction.java:224

  @Override
  public SegmentIdWithShardSpec perform(
      final Task task,
      final TaskActionToolbox toolbox
  )
  {
    if (!(task instanceof PendingSegmentAllocatingTask)) {
      throw DruidException.defensive(
          "Task[%s] of type[%s] cannot allocate segments as it does not implement PendingSegmentAllocatingTask.",
          task.getId(), task.getType()
      );
    }
    int attempt = 0;
    while (true) {
      attempt++;

      if (!task.getDataSource().equals(dataSource)) {
        throw new IAE("Task dataSource must match action dataSource, [%s] != [%s].", task.getDataSource(), dataSource);
      }

      final IndexerMetadataStorageCoordinator msc = toolbox.getIndexerMetadataStorageCoordinator();

      // 1) if something overlaps our timestamp, use that
      // 2) otherwise try preferredSegmentGranularity & going progressively smaller

      final Interval rowInterval = queryGranularity.bucket(timestamp).withChronology(ISOChronology.getInstanceUTC());

      final Set<DataSegment> usedSegmentsForRow =
          new HashSet<>(msc.retrieveUsedSegmentsForInterval(dataSource, rowInterval, Segments.ONLY_VISIBLE));

      final SegmentIdWithShardSpec identifier;
      if (usedSegmentsForRow.isEmpty()) {
        identifier = tryAllocateFirstSegment(toolbox, task, rowInterval);
      } else {
        identifier = tryAllocateSubsequentSegment(toolbox, task, rowInterval, usedSegmentsForRow.iterator().next());
      }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Ensure the datasource in the ingestion spec matches the one in every segment-allocate action; regenerate the task instead of editing its payload.
  2. Resubmit the task/supervisor with a consistent dataSource name.
  3. If renaming a datasource, restart the supervisor/task from scratch rather than reusing old task state.
  4. Check custom task code so SegmentAllocateAction is always constructed with the task's own getDataSource().

Example fix

// before
SegmentAllocateAction action = new SegmentAllocateAction("old-datasource", ...); // in task for "new-datasource"
// after
SegmentAllocateAction action = new SegmentAllocateAction(task.getDataSource(), ...);
Defensive patterns

Strategy: validation

Validate before calling

if (!task.getDataSource().equals(actionDataSource)) {
  throw new IllegalArgumentException("dataSource mismatch: task=" + task.getDataSource() + " action=" + actionDataSource);
}

Try / catch

try { result = action.perform(task, toolbox); } catch (IAE e) { if (e.getMessage().startsWith("Task dataSource must match")) { /* resubmit task with consistent datasource */ } else throw e; }

Prevention

When it happens

Trigger: A task action payload was deserialized with a dataSource different from the task's actual dataSource (hand-crafted or stale task payloads), or custom task code copies a SegmentAllocateAction from another task/context.

Common situations: Manually resubmitting or editing task JSON where the spec dataSource was renamed but the stored action was not; building custom ingestion tasks that reuse an allocate action across specs; replaying old task checkpoints after a datasource rename.

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