apache/dolphinscheduler · warning · TaskException

The current Shell task has been interrupted

Error message

The current Shell task has been interrupted

What it means

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.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java:77

    @SuppressWarnings("unchecked")
    @Override
    public void handle(TaskCallBack taskCallBack) throws TaskException {
        try {
            IShellInterceptorBuilder<?, ?> shellActuatorBuilder = ShellInterceptorBuilderFactory.newBuilder()
                    .properties(ParameterUtils.convert(taskRequest.getPrepareParamsMap()))
                    .appendScript(shellParameters.getRawScript());

            TaskResponse commandExecuteResult = shellCommandExecutor.run(shellActuatorBuilder, taskCallBack);
            setExitStatusCode(commandExecuteResult.getExitStatusCode());
            setProcessId(commandExecuteResult.getProcessId());
            shellParameters.dealOutParam(shellCommandExecutor.getTaskOutputParams());
            taskRequest.setVarPool(shellParameters.getVarPool());
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            log.error("The current Shell task has been interrupted", e);
            setExitStatusCode(EXIT_CODE_FAILURE);
            throw new TaskException("The current Shell task has been interrupted", e);
        } catch (Exception e) {
            log.error("shell task error", e);
            setExitStatusCode(EXIT_CODE_FAILURE);
            throw new TaskException("Execute shell task error", e);
        }
    }

    @Override
    public void cancel() throws TaskException {
        // cancel process
        try {
            shellCommandExecutor.cancelApplication();
        } catch (Exception e) {
            throw new TaskException("cancel application error", e);
        }
    }

    @Override

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. If the task should be allowed to finish, increase the task's timeout setting so the watchdog does not interrupt it
  2. Re-run the task after confirming it was not intentionally killed; treat this exit status as killed rather than a script bug
  3. If kills happen unexpectedly during deployments, drain workers only when no tasks are running or enable failover tolerance

Example fix

// before: long script with 30s task timeout
./long-etl-job.sh
// after: raise task timeout to fit the job
./long-etl-job.sh  # with taskTimeout > job runtime
Defensive patterns

Strategy: try-catch

Try / catch

try {
    shellTask.handle(callBack);
} catch (TaskException e) {
    if (Thread.currentThread().isInterrupted()) {
        // task was killed/interrupted: mark killed, do not retry
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/e0853bc0d6cd4db7. Report an issue: GitHub.