apache/dolphinscheduler · error · ServiceException
CREATE_ENVIRONMENT_ERROR
CREATE_ENVIRONMENT_ERROR
Error message
Status.CREATE_ENVIRONMENT_ERROR
What it means
Thrown by EnvironmentServiceImpl.createEnvironment when the environment row insert returns 0 affected rows (environmentMapper.insert(env) <= 0), meaning no environment was persisted. It is a generic 'insert failed' fallback reached after all validation and uniqueness checks passed.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java:146
workerGroupList.stream().forEach(workerGroup -> {
if (!StringUtils.isEmpty(workerGroup)) {
EnvironmentWorkerGroupRelation relation = new EnvironmentWorkerGroupRelation();
relation.setEnvironmentCode(env.getCode());
relation.setWorkerGroup(workerGroup);
relation.setOperator(loginUser.getId());
relation.setCreateTime(new Date());
relation.setUpdateTime(new Date());
relationMapper.insert(relation);
log.info(
"Environment-WorkerGroup relation create complete, environmentName:{}, workerGroup:{}.",
env.getName(), relation.getWorkerGroup());
}
});
}
}
return env.getCode();
}
throw new ServiceException(Status.CREATE_ENVIRONMENT_ERROR);
}
/**
* query environment paging
*
* @param pageNo page number
* @param searchVal search value
* @param pageSize page size
* @return environment list page
*/
@Override
public Result queryEnvironmentListPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal) {
Result<Object> result = new Result();
Page<Environment> page = new Page<>(pageNo, pageSize);
PageInfo<EnvironmentDto> pageInfo = new PageInfo<>(pageNo, pageSize);
IPage<Environment> environmentIPage;
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {View on GitHub (pinned to 02eac45a1b)
Solutions
- Check api-server logs and the database for constraint violations or connection errors around the insert time.
- Verify the t_ds_environment schema matches the current DolphinScheduler version (run upgrade SQL scripts if the schema is stale).
- Retry the create; if it persists, check datasource connectivity and pool settings in application.yaml.
- Inspect the workerGroups parameter — malformed group entries can cause relation inserts to fail and roll back the whole transaction.
Defensive patterns
Strategy: retry
Validate before calling
// Pre-check DB connectivity before the call
try (Connection c = dataSource.getConnection()) {
if (!c.isValid(3)) throw new IllegalStateException("DB connection invalid");
} Try / catch
try {
environmentService.createEnvironment(loginUser, name, config, desc, workerGroups);
} catch (ServiceException e) {
if (String.valueOf(e.getMessage()).contains("CREATE_ENVIRONMENT_ERROR")) {
// inspect server logs, then retry with backoff
}
} Prevention
- Keep database schema in sync with the DolphinScheduler version (run upgrade scripts)
- Monitor DB connection-pool saturation and constraints in api-server logs
- Validate workerGroups JSON well-formedness before creating environments
When it happens
Trigger: environmentMapper.insert returns 0 despite validation passing — typically a database constraint violation swallowed at the mapper level, a transaction rollback triggered by the worker-group relation inserts, or a DB connection failure during the write.
Common situations: Database schema drift (missing columns after upgrade); DB connection pool exhaustion under load; workerGroups JSON referencing groups that cause relation inserts to fail and roll back the surrounding @Transactional method.
Related errors
- DESCRIPTION_TOO_LONG_ERROR
- ENVIRONMENT_NAME_EXISTS
- QUERY_ENVIRONMENT_BY_CODE_ERROR
- QUERY_ENVIRONMENT_BY_NAME_ERROR
- DELETE_ENVIRONMENT_RELATED_TASK_EXISTS
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/9b84243169445c15.
Report an issue: GitHub.