{"record":{"id":"3c8ebaf2818039e4","repo":"apache/dolphinscheduler","slug":"cancel-linkis-task-error","errorCode":null,"errorMessage":"cancel linkis task error","messagePattern":"cancel linkis task error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-linkis/src/main/java/org/apache/dolphinscheduler/plugin/task/linkis/LinkisTask.java","lineNumber":157,"sourceCode":"        // cancel process\n        initTaskId();\n        try {\n            List<String> args = new ArrayList<>();\n            args.add(Constants.SHELL_CLI_OPTIONS);\n            args.add(Constants.KILL_OPTIONS);\n            args.add(taskId);\n            String command = String.join(Constants.SPACE, args);\n\n            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .appendScript(command);\n            shellCommandExecutor.run(shellActuatorBuilder, null);\n            setExitStatusCode(EXIT_CODE_KILL);\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            log.error(\"The current Linkis task has been interrupted\", e);\n            throw new TaskException(\"The current Linkis task has been interrupted\", e);\n        } catch (Exception e) {\n            throw new TaskException(\"cancel linkis task error\", e);\n        }\n    }\n\n    private String buildCommand() {\n\n        List<String> args = new ArrayList<>();\n        args.addAll(buildOptions());\n\n        String command = String.join(\" \", args);\n        log.info(\"Linkis task command: {}\", command);\n\n        return command;\n    }\n\n    protected List<String> buildOptions() {\n        List<String> args = new ArrayList<>();\n        args.add(Constants.SHELL_CLI_OPTIONS);\n        args.add(Constants.ASYNC_OPTIONS);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-linkis/src/main/java/org/apache/dolphinscheduler/plugin/task/linkis/LinkisTask.java#L139-L175","documentation":"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.","triggerScenarios":"buildCommand() for cancel fails, the shell actuator builder throws, or the cancel command exits abnormally (linkis-cli kill invocation error, missing binary, bad jobId).","commonSituations":"linkis-cli not installed on worker; taskId/appId is null or stale so the kill targets nothing; permission denied executing the kill command.","solutions":["Inspect the caused-by exception; already-dead Linkis tasks may fail the kill command harmlessly","Verify linkis-cli is installed on the worker and the kill options are correct","Manually kill the Linkis job via its task id if the CLI kill fails"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    task.cancelApplication();\n} catch (TaskException e) {\n    log.error(\"Cancel failed: {}\", e.getCause());\n    // fall back to manual kill via Linkis console\n}","preventionTips":["Install and permission-check linkis-cli for the worker user.","Only cancel tasks that produced a valid task id (non-null appId).","Alert on cancel failures so stale Linkis jobs are cleaned up."],"tags":["linkis","cancel","kill","shell-executor"],"backgroundTag":"command-execution-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}