{"record":{"id":"e0853bc0d6cd4db7","repo":"apache/dolphinscheduler","slug":"the-current-shell-task-has-been-interrupted","errorCode":null,"errorMessage":"The current Shell task has been interrupted","messagePattern":"The current Shell task has been interrupted","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java","lineNumber":77,"sourceCode":"\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public void handle(TaskCallBack taskCallBack) throws TaskException {\n        try {\n            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()\n                    .properties(ParameterUtils.convert(taskRequest.getPrepareParamsMap()))\n                    .appendScript(shellParameters.getRawScript());\n\n            TaskResponse commandExecuteResult = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);\n            setExitStatusCode(commandExecuteResult.getExitStatusCode());\n            setProcessId(commandExecuteResult.getProcessId());\n            shellParameters.dealOutParam(shellCommandExecutor.getTaskOutputParams());\n            taskRequest.setVarPool(shellParameters.getVarPool());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            log.error(\"The current Shell task has been interrupted\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"The current Shell task has been interrupted\", e);\n        } catch (Exception e) {\n            log.error(\"shell task error\", e);\n            setExitStatusCode(EXIT_CODE_FAILURE);\n            throw new TaskException(\"Execute shell task error\", e);\n        }\n    }\n\n    @Override\n    public void cancel() 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    @Override","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java#L59-L95","documentation":"ShellTask.handle() runs the shell command through ShellCommandExecutor, which blocks the worker thread. If the thread is interrupted while the process runs (task kill, worker shutdown, timeout), InterruptedException is caught, the interrupt flag is restored, exit status is set to failure, and a TaskException with this message is thrown. It signals the task was externally stopped, not that the script itself failed.","triggerScenarios":"Calling taskExecutionContext cancel/kill while the shell process is running; worker graceful-shutdown interrupting the task thread; a wait-timeout mechanism interrupting the executor thread.","commonSituations":"User clicks stop/kill on a long-running shell task; worker pod being drained in Kubernetes; watchdog timeout configured shorter than the script's runtime.","solutions":["If the task should be allowed to finish, increase the task's timeout setting so the watchdog does not interrupt it","Re-run the task after confirming it was not intentionally killed; treat this exit status as killed rather than a script bug","If kills happen unexpectedly during deployments, drain workers only when no tasks are running or enable failover tolerance"],"exampleFix":"// before: long script with 30s task timeout\n./long-etl-job.sh\n// after: raise task timeout to fit the job\n./long-etl-job.sh  # with taskTimeout > job runtime","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    shellTask.handle(callBack);\n} catch (TaskException e) {\n    if (Thread.currentThread().isInterrupted()) {\n        // task was killed/interrupted: mark killed, do not retry\n    }\n}","preventionTips":["Set task timeout comfortably above the expected script runtime","Drain/stop workers only when no tasks are running","Treat this exit status as 'killed' in monitoring rather than a script defect and skip retries"],"tags":["interruption","task-kill","concurrency"],"backgroundTag":"task-thread-interrupted","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"}