apache/dolphinscheduler · warning · TaskException
cancel application error
Error message
cancel application error
What it means
ShellTask.cancel() delegates to ShellCommandExecutor.cancelApplication() to kill the running process. Any exception during the cancel (e.g. the process handle is invalid or the executor was never started) is wrapped as TaskException("cancel application error"). This means the task could not be stopped cleanly; the original process may still be running.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java:91
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("The current Shell task has been interrupted", e);
setExitStatusCode(EXIT_CODE_FAILURE);
throw new TaskException("The current Shell task has been interrupted", e);
} catch (Exception e) {
log.error("shell task error", e);
setExitStatusCode(EXIT_CODE_FAILURE);
throw new TaskException("Execute shell task error", e);
}
}
@Override
public void cancel() throws TaskException {
// cancel process
try {
shellCommandExecutor.cancelApplication();
} catch (Exception e) {
throw new TaskException("cancel application error", e);
}
}
@Override
public AbstractParameters getParameters() {
return shellParameters;
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Retry the cancel after a short delay if the process was still starting; otherwise ignore the failure since the process already exited
- If processes keep running, kill leftovers on the worker host (check with ps for the task's shell process) and clean up the task instance
- Check the wrapped exception: if the executor was null, fix the init() failure first — cancel cannot work without a started executor
Example fix
// before: cancel on never-initialized task
TaskExecutionContext ctx = ...; // params invalid, init() failed
shellTask.cancel(); // throws 'cancel application error'
// after: check state before cancelling
if (taskInstance.getState() == ExecutionStatus.RUNNING_EXECUTION) {
shellTask.cancel();
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean cancellable = taskInstance.getState() == ExecutionStatus.RUNNING_EXECUTION
&& shellTask != null; Try / catch
try {
shellTask.cancel();
} catch (TaskException e) {
// process likely already exited; check cause, don't fail the kill pipeline
log.warn("cancel failed (process may be gone)", e);
} Prevention
- Only cancel tasks in a running state
- Fix init() failures before attempting cancel — a failed init leaves no executor to cancel
- Reconcile leftover worker processes after abrupt worker crashes
When it happens
Trigger: Calling cancel() on a ShellTask whose shell process has already exited or whose shellCommandExecutor was not initialized (init() failed earlier); kill issued via ProcessBuilder/OS while the process object is in an unexpected state.
Common situations: Double-clicking kill on a task (second cancel hits an already-dead process); cancelling a task that failed during init() before the executor existed; orphaned processes on the worker after an abrupt worker crash.
Related errors
- cancel application error
- cancel application error
- "WorkflowSerialCoordinator is already started"
- "InternalThread is already started"
- ${this} has already started
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/46157d3ad3208c15.
Report an issue: GitHub.