{"record":{"id":"4282f0a73a8f4b9b","repo":"apache/dolphinscheduler","slug":"the-current-yarn-task-has-been-interrupted","errorCode":null,"errorMessage":"The current yarn task has been interrupted","messagePattern":"The current yarn task has been interrupted","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":62,"sourceCode":"    // todo split handle to submit and track\n    @Override\n    public void handle(TaskCallBack taskCallBack) throws TaskException {\n        try {\n            IShellInterceptorBuilder shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .properties(ParameterUtils.convert(taskRequest.getPrepareParamsMap()))\n                    // todo: do we need to move the replace to subclass?\n                    .appendScript(getScript().replaceAll(\"\\\\r\\\\n\", System.lineSeparator()));\n            // SHELL task exit code\n            TaskResponse response = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);\n            setExitStatusCode(response.getExitStatusCode());\n            // set appIds\n            setAppIds(String.join(TaskConstants.COMMA, getApplicationIds()));\n            setProcessId(response.getProcessId());\n        } catch (InterruptedException ex) {\n            Thread.currentThread().interrupt();\n            log.info(\"The current yarn task has been interrupted\", ex);\n            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);\n            throw new TaskException(\"The current yarn task has been interrupted\", ex);\n        } catch (Exception e) {\n            log.error(\"yarn process failure\", e);\n            exitStatusCode = -1;\n            throw new TaskException(\"Execute task failed\", e);\n        }\n    }\n\n    // todo\n    @Override\n    public void submitApplication() throws TaskException {\n\n    }\n\n    // todo\n    @Override\n    public void trackApplicationStatus() throws TaskException {\n\n    }","sourceCodeStart":44,"sourceCodeEnd":80,"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#L44-L80","documentation":"AbstractYarnTask.handle catches InterruptedException while waiting for the shell process that launches the Yarn application, sets the exit code to failure, and rethrows as TaskException with this message. It means the thread blocked on the task process was interrupted, typically by a kill/cancel or worker shutdown.","triggerScenarios":"Thread interrupted while response = runProcess()/waiting on the shell command for the Yarn job — user cancels the task in the UI, workflow is killed, or the worker is shutting down and interrupts task threads.","commonSituations":"Operator kills a stuck Yarn task; worker graceful shutdown interrupts in-flight tasks; master failover cancels running task threads; timeout-kill path interrupting the process wait.","solutions":["Treat as expected when you cancelled the task yourself","Check worker logs for shutdown/kill events around the interruption time","Re-run the workflow/task after the interruption cause is resolved","Ensure Hadoop/YARN application state is cleaned up (check for orphaned applications)","If spurious, investigate what interrupts the task thread (executor shutdown, watchdog)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    yarnTask.handle(taskCallBack);\n} catch (TaskException e) {\n    if (e.getCause() instanceof InterruptedException) {\n        log.warn(\"Yarn task was interrupted (cancelled or worker shutdown)\");\n        // restore cleanup state, check YARN for orphaned applications\n    } else {\n        throw e;\n    }\n}","preventionTips":["Avoid killing workflows while Yarn jobs are in a critical phase","Plan worker shutdowns outside of in-flight task windows","Always check YARN for orphaned applications after interruption","Rely on EXIT_CODE_FAILURE being set — do not retry blindly"],"tags":["yarn","interrupted","task-cancel"],"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"}