apache/dolphinscheduler · error · TaskException

cancel application error

Error message

cancel application error

What it means

RemoteShellTask.cancel tries to kill the remote process via remoteExecutor.kill(taskId); any exception is wrapped into TaskException("cancel application error"). Failure means the remote process may still be alive after a stop/timeout request.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-remoteshell/src/main/java/org/apache/dolphinscheduler/plugin/task/remoteshell/RemoteShellTask.java:118

            String localFile = buildCommand();
            int exitCode = remoteExecutor.run(taskId, localFile);
            setExitStatusCode(exitCode);
            remoteShellParameters.dealOutParam(remoteExecutor.getTaskOutputParams());
        } 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 {
            log.info("kill remote task {}", taskId);
            remoteExecutor.kill(taskId);
        } catch (Exception e) {
            throw new TaskException("cancel application error", e);
        }
    }

    /**
     * create command
     *
     * @return file name
     * @throws Exception exception
     */
    public String buildCommand() throws Exception {
        // generate scripts
        String fileName = String.format("%s/%s_node.%s",
                taskExecutionContext.getExecutePath(),
                taskExecutionContext.getTaskAppId(), SystemUtils.IS_OS_WINDOWS ? "bat" : "sh");

        File file = new File(fileName);
        Path path = file.toPath();

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the cause: 'no such process' means the task already ended and the kill failure is harmless.
  2. Verify the worker can still SSH to the remote host to issue the kill command.
  3. Confirm the SSH user owns or has rights to kill the remote process.
  4. Manually kill the orphaned remote process (using the pid from logs) and verify no zombie processes remain.

Example fix

// before
} catch (Exception e) {
    throw new TaskException("cancel application error", e);
}
// after: tolerate already-finished remote process
} catch (Exception e) {
    log.warn("Failed to kill remote task {}; it may have already finished", taskId, e);
    throw new TaskException("cancel application error: " + e.getMessage(), e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    remoteShellTask.cancel();
} catch (TaskException e) {
    if (e.getCause() != null && e.getCause().getMessage().contains("No such process")) {
        logger.info("Remote task already finished; kill unnecessary");
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: User stops the task or a timeout/fault-tolerance kill occurs and remoteExecutor.kill(taskId) throws — e.g., SSH session cannot be established to run the kill, or the remote pid no longer exists.

Common situations: Remote host unreachable during kill; task already completed so the pid is gone; SSH user lacks permission to kill the process; tracking file with the pid was deleted.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/44e1294480d29bcd. Report an issue: GitHub.