{"record":{"id":"2d69c20b46469aef","repo":"apache/dolphinscheduler","slug":"cancel-application-error","errorCode":null,"errorMessage":"cancel application error","messagePattern":"cancel application error","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java","lineNumber":93,"sourceCode":"\n    // todo\n    @Override\n    public void trackApplicationStatus() throws TaskException {\n\n    }\n\n    /**\n     * cancel application\n     *\n     * @throws TaskException exception\n     */\n    @Override\n    public void cancelApplication() throws TaskException {\n        // cancel process\n        try {\n            shellCommandExecutor.cancelApplication();\n        } catch (Exception e) {\n            throw new TaskException(\"cancel application error\", e);\n        }\n    }\n\n    /**\n     * get application ids\n     * @return\n     * @throws TaskException\n     */\n    @Override\n    public List<String> getApplicationIds() throws TaskException {\n        return LogUtils.getAppIds(taskRequest.getLogPath(), taskRequest.getAppInfoPath(),\n                PropertyUtils.getString(APPID_COLLECT, DEFAULT_COLLECT_WAY));\n    }\n\n    /**\n     * Get the script used to bootstrap the task\n     */\n    protected abstract String getScript();","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java#L75-L111","documentation":"cancelApplication wraps any exception from shellCommandExecutor.cancelApplication() into TaskException('cancel application error'). The attempt to kill the underlying shell process / Yarn application failed.","triggerScenarios":"shellCommandExecutor.cancelApplication() throws while killing the process tree — the process already exited, the kill command (kill/pkill, sudo) fails, or an IO error occurs.","commonSituations":"User cancels a task whose process already terminated (race); worker lacks permission to kill the process owner's processes (non-root sudo config); PID file lost after worker restart.","solutions":["Check the wrapped cause; 'no such process' races are harmless and can be ignored","Verify worker kill configuration (sudo permissions for the tenant user / KillProcessID)","Ensure shellCommandExecutor state is intact (worker didn't restart mid-task)","Clean up orphaned YARN applications manually if the OS kill failed","Retry cancellation or use YARN kill application for the running app"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    task.cancelApplication();\n} catch (TaskException e) {\n    if (e.getCause() != null && e.getCause().getMessage() != null\n            && e.getCause().getMessage().contains(\"No such process\")) {\n        log.info(\"Process already exited; cancel is a no-op\");\n    } else {\n        log.warn(\"Cancel failed, verify no orphaned YARN application\", e);\n    }\n}","preventionTips":["Configure worker kill permissions (sudo rules for tenant users)","Avoid worker restarts mid-task; they break PID tracking","After failed cancels, verify YARN applications and kill orphans manually","Expect races where the process exits just before cancel"],"tags":["yarn","cancel","process-kill"],"backgroundTag":"task-cancelled","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"}