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
- Ensure the datasource in the ingestion spec matches the one in every segment-allocate action; regenerate the task instead of editing its payload.
- Resubmit the task/supervisor with a consistent dataSource name.
- If renaming a datasource, restart the supervisor/task from scratch rather than reusing old task state.
- 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
- Never hand-edit task JSON payloads; resubmit from the original spec.
- Construct SegmentAllocateAction from task.getDataSource() in custom tasks.
- Regenerate tasks after datasource renames.
- Validate spec datasource in CI for custom task code.
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
- Batched segment allocation is disabled
- The lock for interval[%s] is preempted and no longer valid
- Cannot allocate segment if not leader.
- Batched segment allocation is disabled.
- Could not find interval for timestamp [%s]
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/f3528ce1eb9b3566.
Report an issue: GitHub.