apache/dolphinscheduler · error · ServiceException
10015
10015
Error message
data source name already exists
What it means
During createDataSource, checkName(name) queries the datasource table for an existing record with the same name; if found, Status.DATASOURCE_EXIST (code 10015) is thrown because datasource names must be unique.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java:96
@Autowired
private DataSourceUserDao datasourceUserDao;
private static final String TABLE = "TABLE";
private static final String VIEW = "VIEW";
private static final String[] TABLE_TYPES = new String[]{TABLE, VIEW};
private static final String TABLE_NAME = "TABLE_NAME";
private static final String COLUMN_NAME = "COLUMN_NAME";
@Override
public DataSource createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) {
DataSourceUtils.checkDatasourceParam(datasourceParam);
if (!canOperatorPermissions(loginUser, null, AuthorizationType.DATASOURCE,
ApiFuncIdentificationConstant.DATASOURCE_CREATE_DATASOURCE)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
// check name can use or not
if (checkName(datasourceParam.getName())) {
throw new ServiceException(Status.DATASOURCE_EXIST);
}
if (checkDescriptionLength(datasourceParam.getNote())) {
throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);
}
ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(datasourceParam);
// build datasource
DataSource dataSource = new DataSource();
Date now = new Date();
dataSource.setName(datasourceParam.getName().trim());
dataSource.setNote(datasourceParam.getNote());
dataSource.setUserId(loginUser.getId());
dataSource.setUserName(loginUser.getUserName());
dataSource.setType(datasourceParam.getType());
dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam));
dataSource.setCreateTime(now);
dataSource.setUpdateTime(now);View on GitHub (pinned to 02eac45a1b)
Solutions
- Pick a unique name (or suffix it with env/timestamp) before creating.
- Query existing datasources first and reuse/update the existing entry instead of creating.
- Delete or rename the conflicting datasource if it is stale.
Example fix
// before
params.setName("mysql-prod"); // already exists
// after
params.setName("mysql-prod-" + env); // or update the existing datasource Defensive patterns
Strategy: validation
Validate before calling
boolean nameTaken = api.getDatasourcesByName(name).size() > 0;
if (nameTaken) { name = name + "-" + System.currentTimeMillis(); } Try / catch
try { ds = api.createDataSource(user, param); } catch (ServiceException e) { if (e.getCode() == 10015) { ds = findByName(param.getName()); } else throw e; } Prevention
- Make provisioning scripts idempotent (create-or-get)
- Prefix names with environment/team to reduce collisions
- Query existing datasources before creating
When it happens
Trigger: POST /datasources whose 'name' matches an already-created datasource (checkName returns true before insert).
Common situations: Re-running an idempotent-looking setup script twice; clicking create twice in the UI; re-importing a workflow that references an existing datasource name.
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/462684d9d27a7a68.
Report an issue: GitHub.