apache/druid · error · IllegalStateException
trying to add taskGroup with id
Error message
trying to add taskGroup with id [%s] to actively reading task groups, but group already exists.
What it means
addTaskGroup (createTaskGroup) inserts a new TaskGroup into activelyReadingTaskGroups with putIfAbsent; a non-null return means a group with that id already exists. Since task group ids derive from partition-group versions, this signals state corruption or a race where two threads/paths tried to create the same group, so an ISE is thrown.
Solutions
- Restart the supervisor to rebuild task group state cleanly
- Check logs for prior killTaskGroupForPartitions failures; ensure groups are removed before re-creation
- Upgrade Druid if hitting a known race-condition bug in group creation
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
if (activelyReadingTaskGroups.containsKey(taskGroupId)) {
return activelyReadingTaskGroups.get(taskGroupId); // reuse instead of re-creating
} Try / catch
try {
group = supervisor.createTaskGroup(taskGroupId, partitions, tasks);
} catch (IllegalStateException e) {
if (e.getMessage().contains("group already exists")) {
group = supervisor.getActivelyReadingTaskGroups().get(taskGroupId);
} else throw e;
} Prevention
- Ensure task groups are removed (killTaskGroupForPartitions) before re-creation with the same id
- Avoid running multiple supervisor instances for the same datasource
- Upgrade Druid if hitting known group-creation race bugs
When it happens
Trigger: Two concurrent calls creating the same taskGroupId (same partition allocation and same partitionGroups version), or re-creating a group that was never removed from activelyReadingTaskGroups (e.g. after killTaskGroupForPartitions failed to run).
Common situations: Supervisor race conditions during task group recycling; version not incremented after killing groups; supervisor state partially restored after restart.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Cannot find taskGroup
- Task[ ] already exists in taskGroup[ ] with data[ ]
- Already started
- authResult.getErrorMessage()
- Backfill tasks require 'useConcurrentLocks' to be set to…
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/a2675c0bbde66590.
Report an issue: GitHub.
Appendix: source
Thrown at indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:1972
Set<String> tasks,
Set<PartitionIdType> exclusiveStartingSequencePartitions,
@Nullable Map<String, Integer> taskIdToServerPriority
)
{
TaskGroup group = new TaskGroup(
taskGroupId,
partitionOffsets,
null,
minMsgTime,
maxMsgTime,
exclusiveStartingSequencePartitions
);
group.tasks.putAll(tasks.stream().collect(Collectors.toMap(x -> x, x -> new TaskData())));
if (taskIdToServerPriority != null) {
group.taskIdToServerPriority.putAll(taskIdToServerPriority);
}
if (activelyReadingTaskGroups.putIfAbsent(taskGroupId, group) != null) {
throw new ISE(
"trying to add taskGroup with id [%s] to actively reading task groups, but group already exists.",
taskGroupId
);
}
return group;
}
@VisibleForTesting
public TaskGroup addTaskGroupToPendingCompletionTaskGroup(
int taskGroupId,
ImmutableMap<PartitionIdType, SequenceOffsetType> partitionOffsets,
@Nullable DateTime minMsgTime,
@Nullable DateTime maxMsgTime,
Set<String> tasks,
Set<PartitionIdType> exclusiveStartingSequencePartitions,
@Nullable Map<String, Integer> taskIdToServerPriority
)
{View on GitHub (pinned to 9b90983fd2)