apache/dolphinscheduler · error · TaskException
Cancel application failed!
Error message
Cancel application failed!
What it means
ProcessUtils.cancelApplication() kills a Yarn application associated with a task. Before doing so it requires logPath, appInfoPath, executePath, and tenantCode; if any is null it logs the offending inputs and throws TaskException 'Cancel application failed!'. The kill cannot proceed without these paths to locate the appIds.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:374
taskExecutionContext.getK8sTaskExecutionContext(),
taskExecutionContext.getTaskAppId(), ""));
}
} else {
String host = taskExecutionContext.getHost();
String executePath = taskExecutionContext.getExecutePath();
String tenantCode = taskExecutionContext.getTenantCode();
List<String> appIds;
if (StringUtils.isNotEmpty(taskExecutionContext.getAppIds())) {
// is failover
appIds = Arrays.asList(taskExecutionContext.getAppIds().split(COMMA));
} else {
String logPath = taskExecutionContext.getLogPath();
String appInfoPath = taskExecutionContext.getAppInfoPath();
if (logPath == null || appInfoPath == null || executePath == null || tenantCode == null) {
log.error(
"Kill yarn job error, the input params is illegal, host: {}, logPath: {}, appInfoPath: {}, executePath: {}, tenantCode: {}",
host, logPath, appInfoPath, executePath, tenantCode);
throw new TaskException("Cancel application failed!");
}
log.info("Get appIds from worker {}, taskLogPath: {}", host, logPath);
appIds = LogUtils.getAppIds(logPath, appInfoPath,
PropertyUtils.getString(APPID_COLLECT, DEFAULT_COLLECT_WAY));
taskExecutionContext.setAppIds(String.join(TaskConstants.COMMA, appIds));
}
if (CollectionUtils.isEmpty(appIds)) {
log.info("The appId is empty");
return;
}
ApplicationManager applicationManager = applicationManagerMap.get(ResourceManagerType.YARN);
applicationManager.killApplication(new YarnApplicationManagerContext(executePath, tenantCode, appIds));
log.info("yarn application [{}] is killed or already finished", appIds);
}
} catch (Exception e) {
log.error("Cancel application failed: {}", e.getMessage());
}
}View on GitHub (pinned to 02eac45a1b)
Solutions
- Read the preceding log.error line — it lists exactly which parameter(s) are null.
- Ensure the task execution directory (executePath) and tenant code are correctly set in the task context.
- Verify the Yarn task produces appInfoPath (appIds file) — check APPID_COLLECT config (log vs application_url).
- Confirm logPath points to an existing task log on the target host.
- If the app already finished, treat this as non-fatal cleanup and skip the kill.
Example fix
// before
// cancel path with null appInfoPath (task failed before submission)
processUtils.cancelApplication(taskExecutionContext, host);
// after
if (taskExecutionContext.getAppInfoPath() != null && new File(taskExecutionContext.getLogPath()).exists()) {
processUtils.cancelApplication(taskExecutionContext, host);
} else {
log.info("no yarn app to cancel for task {}", taskExecutionContext.getTaskInstanceId());
} Defensive patterns
Strategy: validation
Validate before calling
TaskExecutionContext ctx = taskExecutionContext;
if (ctx.getLogPath() == null || ctx.getAppInfoPath() == null ||
ctx.getExecutePath() == null || ctx.getTenantCode() == null) {
log.warn("skip yarn cancel: incomplete context (log/appInfo/executePath/tenantCode)");
return;
} Type guard
boolean canCancelYarn(TaskExecutionContext c) {
return c != null && c.getLogPath() != null && c.getAppInfoPath() != null
&& c.getExecutePath() != null && c.getTenantCode() != null;
} Try / catch
try {
ProcessUtils.cancelApplication(ctx, host);
} catch (TaskException e) {
log.warn("yarn cancel failed (context may be incomplete)", e); // non-fatal for cleanup
} Prevention
- Populate executePath, logPath, appInfoPath and tenantCode before any task that may hit Yarn.
- Configure app-id collection (APPID_COLLECT) so appInfoPath is always written.
- Treat cancel-time failures as best-effort cleanup in your cancellation flow.
When it happens
Trigger: Canceling a task on a Yarn host when the TaskExecutionContext has a null logPath, appInfoPath, executePath, or tenantCode — e.g. execution directory was never created, app info file not configured, or tenant resolution failed.
Common situations: Killing a task that failed early (paths never populated); workers with misconfigured resource/tmp storage directories; Hadoop/Yarn tasks where appIds collection (APPID_COLLECT) settings disabled app-info output; task state mismatch after worker restart.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The current yarn task has been interrupted
- Execute task failed
- cancel application error
- fail to create job
- fail to delete job
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/6c52545686bf43d5.
Report an issue: GitHub.