apache/dolphinscheduler · error · ServiceException
TASK_GROUP_NAME_EXSIT
TASK_GROUP_NAME_EXSIT
Error message
Task group with the same name already exists, taskGroupName:{}. What it means
createTaskGroup enforces per-user name uniqueness: it queries taskGroupMapper.queryByName(loginUser.getId(), name) and, if a duplicate is found, throws ServiceException(Status.TASK_GROUP_NAME_EXSIT). Task group names must be unique within a user's scope, so creation is refused and the transaction rolls back.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupServiceImpl.java:94
@Override
@Transactional
public TaskGroup createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {
requireProjectPerm(loginUser, projectCode, true);
if (checkDescriptionLength(description)) {
log.warn("Parameter description is too long.");
throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);
}
if (name == null) {
log.warn("Parameter name can ot be null.");
throw new ServiceException(Status.NAME_NULL);
}
if (groupSize <= 0) {
log.warn("Parameter task group size is must bigger than 1.");
throw new ServiceException(Status.TASK_GROUP_SIZE_ERROR);
}
TaskGroup duplicate = taskGroupMapper.queryByName(loginUser.getId(), name);
if (duplicate != null) {
log.warn("Task group with the same name already exists, taskGroupName:{}.", duplicate.getName());
throw new ServiceException(Status.TASK_GROUP_NAME_EXSIT);
}
Date now = new Date();
TaskGroup taskGroup = TaskGroup.builder()
.name(name)
.projectCode(projectCode)
.description(description)
.groupSize(groupSize)
.userId(loginUser.getId())
.status(Flag.YES)
.createTime(now)
.updateTime(now)
.build();
if (taskGroupMapper.insert(taskGroup) <= 0) {
log.error("Create task group error, taskGroupName:{}.", taskGroup.getName());
throw new ServiceException(Status.CREATE_TASK_GROUP_ERROR);
}View on GitHub (pinned to 02eac45a1b)
Solutions
- Query existing task groups first and reuse or rename before creating.
- Catch TASK_GROUP_NAME_EXSIT and surface a 'name already in use' message prompting a new name.
- Adopt a naming convention with suffixes (project/env/date) to avoid collisions.
- If the old group is stale, delete or rename it, then create the new one.
Example fix
// before
await createTaskGroup({ name: 'etl-group', groupSize: 10 }) // fails on retry
// after
const existing = await queryTaskGroupList({ searchVal: 'etl-group' })
if (!existing.totalList.some(g => g.name === 'etl-group')) {
await createTaskGroup({ name: 'etl-group', groupSize: 10 })
} Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await queryTaskGroupList({ searchVal: name })
const isDuplicate = existing.totalList?.some(g => g.name === name)
if (isDuplicate) throw new Error(`Task group '${name}' already exists`) Try / catch
try {
await createTaskGroup(payload)
} catch (e) {
if (isServiceException(e, 'TASK_GROUP_NAME_EXSIT')) {
const alt = `${payload.name}-${Date.now()}`
await createTaskGroup({ ...payload, name: alt })
} else throw e
} Prevention
- Check for an existing group with the same name before creating (search-then-create).
- Use namespaced naming conventions (user/project/env) to reduce collisions.
- Make retry scripts idempotent: look up before create instead of blind re-post.
- Surface the server error as a friendly 'name already in use' prompt.
When it happens
Trigger: Creating a task group whose name already exists for the same user; re-running an idempotency-assuming provisioning script; two tabs submitting the same form twice.
Common situations: Retry after a timeout that actually succeeded; migration scripts re-importing groups; teams sharing a service account hitting the same names; misspelled 'rename then create' flows.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/3ac100bfa933fda7.
Report an issue: GitHub.