{"record":{"id":"a2675c0bbde66590","repo":"apache/druid","slug":"trying-to-add-taskgroup-with-id-s-to-actively-r","errorCode":null,"errorMessage":"trying to add taskGroup with id [%s] to actively reading task groups, but group already exists.","messagePattern":"trying to add taskGroup with id \\[(.+?)\\] to actively reading task groups, but group already exists\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java","lineNumber":1972,"sourceCode":"      Set<String> tasks,\n      Set<PartitionIdType> exclusiveStartingSequencePartitions,\n      @Nullable Map<String, Integer> taskIdToServerPriority\n  )\n  {\n    TaskGroup group = new TaskGroup(\n        taskGroupId,\n        partitionOffsets,\n        null,\n        minMsgTime,\n        maxMsgTime,\n        exclusiveStartingSequencePartitions\n    );\n    group.tasks.putAll(tasks.stream().collect(Collectors.toMap(x -> x, x -> new TaskData())));\n    if (taskIdToServerPriority != null) {\n      group.taskIdToServerPriority.putAll(taskIdToServerPriority);\n    }\n    if (activelyReadingTaskGroups.putIfAbsent(taskGroupId, group) != null) {\n      throw new ISE(\n          \"trying to add taskGroup with id [%s] to actively reading task groups, but group already exists.\",\n          taskGroupId\n      );\n    }\n    return group;\n  }\n\n  @VisibleForTesting\n  public TaskGroup addTaskGroupToPendingCompletionTaskGroup(\n      int taskGroupId,\n      ImmutableMap<PartitionIdType, SequenceOffsetType> partitionOffsets,\n      @Nullable DateTime minMsgTime,\n      @Nullable DateTime maxMsgTime,\n      Set<String> tasks,\n      Set<PartitionIdType> exclusiveStartingSequencePartitions,\n      @Nullable Map<String, Integer> taskIdToServerPriority\n  )\n  {","sourceCodeStart":1954,"sourceCodeEnd":1990,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java#L1954-L1990","documentation":"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.","triggerScenarios":"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).","commonSituations":"Supervisor race conditions during task group recycling; version not incremented after killing groups; supervisor state partially restored after restart.","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"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"if (activelyReadingTaskGroups.containsKey(taskGroupId)) {\n  return activelyReadingTaskGroups.get(taskGroupId); // reuse instead of re-creating\n}","typeGuard":null,"tryCatchPattern":"try {\n  group = supervisor.createTaskGroup(taskGroupId, partitions, tasks);\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"group already exists\")) {\n    group = supervisor.getActivelyReadingTaskGroups().get(taskGroupId);\n  } else throw e;\n}","preventionTips":["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"],"tags":["supervisor","race-condition","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}