{"record":{"id":"e091fb312ffc6299","repo":"apache/dolphinscheduler","slug":"the-current-chunjun-task-has-been-interrupted","errorCode":null,"errorMessage":"The current ChunJun Task has been interrupted","messagePattern":"The current ChunJun Task has been interrupted","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-chunjun/src/main/java/org/apache/dolphinscheduler/plugin/task/chunjun/ChunJunTask.java","lineNumber":102,"sourceCode":"    public void handle(TaskCallBack taskCallBack) throws TaskException {\n        try {\n            Map<String, Property> paramsMap = taskRequest.getPrepareParamsMap();\n\n            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .properties(ParameterUtils.convert(paramsMap))\n                    .appendScript(buildCommand(buildChunJunJsonFile(paramsMap)));\n            TaskResponse commandExecuteResult = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);\n\n            setExitStatusCode(commandExecuteResult.getExitStatusCode());\n\n            // todo get applicationId\n            setAppIds(String.join(TaskConstants.COMMA, Collections.emptySet()));\n            setProcessId(commandExecuteResult.getProcessId());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            log.error(\"The current ChunJun Task has been interrupted\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"The current ChunJun Task has been interrupted\", e);\n        } catch (Exception e) {\n            log.error(\"chunjun task failed.\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"Execute chunjun task failed\", e);\n        }\n    }\n\n    /**\n     * build chunjun json file\n     *\n     * @param paramsMap\n     * @return\n     * @throws Exception\n     */\n    private String buildChunJunJsonFile(Map<String, Property> paramsMap) throws Exception {\n        // generate json\n        String fileName = String.format(\"%s/%s_job.json\", taskRequest.getExecutePath(), taskRequest.getTaskAppId());\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-chunjun/src/main/java/org/apache/dolphinscheduler/plugin/task/chunjun/ChunJunTask.java#L84-L120","documentation":"ChunJunTask.handle() runs the ChunJun shell/submit command; when the waiting thread is interrupted it restores the interrupt flag, sets exit code to failure, and throws TaskException 'The current ChunJun Task has been interrupted'. This occurs when the task is killed/canceled by DolphinScheduler while the subprocess is running.","triggerScenarios":"Calling handle() and having the worker thread interrupted — user kills/cancels the workflow instance, the task times out and is cancelled, or the worker shuts down while ShellCommandExecutor is waiting for the ChunJun process.","commonSituations":"Users stop a long-running ChunJun (Flink batch/stream) job from the UI; task timeout policy triggers kill; worker graceful shutdown during deployment; process hangs (e.g. waiting on Yarn resources) and is force-cancelled.","solutions":["This is usually an intentional cancel — verify the task status in the UI and re-run if needed.","Check Yarn/Flink job state to ensure the ChunJun process was actually terminated and clean up orphan jobs.","Increase the task timeout if legitimate runs are being interrupted by the timeout policy.","If workers are being restarted frequently, schedule graceful shutdowns outside task execution windows.","Inspect worker logs just before the interruption for the originating cancel/kill event."],"exampleFix":"// before\n// task timeout: 3600s, ChunJun streaming job needs longer\n<task timeout=3600 timeoutPolicy=KILL>\n// after\n<task timeout=86400 timeoutPolicy=FAILED>\n// or use streaming-safe scheduling without aggressive kill","handlingStrategy":"try-catch","validationCode":"// before submit\nif (task.getTaskTimeout() < expectedJobDurationSeconds) {\n    throw new IllegalStateException(\"timeout too short for chunjun job\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.handle(callback);\n} catch (TaskException e) {\n    if (e.getMessage().contains(\"interrupted\")) {\n        log.warn(\"chunjun task cancelled; ensure yarn/flink job is killed\", e);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Set generous timeouts and FAILED (not KILL) policy for long-running ChunJun jobs.","On cancellation, verify and clean up the corresponding Yarn/Flink application.","Avoid worker restarts during streaming/batch job execution windows."],"tags":["chunjun","interruption","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-14T05:17:10.506Z"}