apache/dolphinscheduler · error · TaskException

cancel linkis task error

Error message

cancel linkis task error

What it means

The Linkis task's cancel path failed while building/running the `sh linkis-cli --kill <taskId>` shell command — InterruptedException during cancellation, a failure initializing taskId (initTaskId), or ShellCommandExecutor.run throwing. It is a cancellation-path failure: the task was being killed and the kill command itself errored; the exit code is set to KILL before the wrap in TaskException.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-linkis/src/main/java/org/apache/dolphinscheduler/plugin/task/linkis/LinkisTask.java:157

        // cancel process
        initTaskId();
        try {
            List<String> args = new ArrayList<>();
            args.add(Constants.SHELL_CLI_OPTIONS);
            args.add(Constants.KILL_OPTIONS);
            args.add(taskId);
            String command = String.join(Constants.SPACE, args);

            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()
                    .appendScript(command);
            shellCommandExecutor.run(shellActuatorBuilder, null);
            setExitStatusCode(EXIT_CODE_KILL);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            log.error("The current Linkis task has been interrupted", e);
            throw new TaskException("The current Linkis task has been interrupted", e);
        } catch (Exception e) {
            throw new TaskException("cancel linkis task error", e);
        }
    }

    private String buildCommand() {

        List<String> args = new ArrayList<>();
        args.addAll(buildOptions());

        String command = String.join(" ", args);
        log.info("Linkis task command: {}", command);

        return command;
    }

    protected List<String> buildOptions() {
        List<String> args = new ArrayList<>();
        args.add(Constants.SHELL_CLI_OPTIONS);
        args.add(Constants.ASYNC_OPTIONS);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Inspect the caused-by exception; already-dead Linkis tasks may fail the kill command harmlessly
  2. Verify linkis-cli is installed on the worker and the kill options are correct
  3. Manually kill the Linkis job via its task id if the CLI kill fails
Defensive patterns

Strategy: try-catch

Try / catch

try {
    task.cancelApplication();
} catch (TaskException e) {
    log.error("Cancel failed: {}", e.getCause());
    // fall back to manual kill via Linkis console
}

Prevention

When it happens

Trigger: buildCommand() for cancel fails, the shell actuator builder throws, or the cancel command exits abnormally (linkis-cli kill invocation error, missing binary, bad jobId).

Common situations: linkis-cli not installed on worker; taskId/appId is null or stale so the kill targets nothing; permission denied executing the kill command.

Related errors


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