apache/dolphinscheduler · error · TaskException

cancel application error

Error message

cancel application error

What it means

DataxTask.cancel() delegates cancellation of the running DataX shell process to ShellCommandExecutor.cancelApplication(). If that call throws for any reason (process already dead, kill failure, interrupted), the exception is wrapped in a TaskException with the message 'cancel application error'. It signals that the worker could not cleanly stop the DataX job process.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java:169

        } catch (Exception e) {
            log.error("datax task error", e);
            setExitStatusCode(EXIT_CODE_FAILURE);
            throw new TaskException("Execute DataX task failed", e);
        }
    }

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

    /**
     * Reads the DataX job definition from the designated json resource file. The worker has
     * already downloaded resources into the execution directory by the time the task runs.
     */
    private String readJsonFromResourceFile(ResourceInfo jobResource) throws Exception {
        String resourceFileName = jobResource.getResourceName();
        ResourceContext resourceContext = taskRequest.getResourceContext();
        return FileUtils.readFileToString(
                new File(resourceContext.getResourceItem(resourceFileName).getResourceAbsolutePathInLocal()),
                StandardCharsets.UTF_8);
    }

    /**
     * build datax configuration file
     *

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check worker logs for the wrapped cause to see why the kill failed (process already gone vs. permission vs. interrupted).
  2. If caused by an already-exited process, treat as benign and rely on the process exit code recorded by the executor.
  3. Ensure the worker OS user has permission to kill the DataX child processes (same user, sufficient ulimits).
  4. Retry cancellation or force-kill leftover DataX processes manually (pkill -f datax).

Example fix

// before
try {
    shellCommandExecutor.cancelApplication();
} catch (Exception e) {
    throw new TaskException("cancel application error", e);
}
// after
try {
    shellCommandExecutor.cancelApplication();
} catch (Exception e) {
    log.warn("cancel application error (process may have already exited)", e);
    throw new TaskException("cancel application error", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// no pre-call check possible; ensure process is alive before cancelling
boolean cancellable = task.getProcessId() > 0;

Try / catch

try {
    task.cancel();
} catch (TaskException e) {
    log.warn("DataX task cancel failed (may have already exited): {}", e.getCause());
}

Prevention

When it happens

Trigger: Calling cancel() on a DataxTask while shellCommandExecutor.cancelApplication() throws — e.g. the underlying process handle is stale, the OS kill command fails, or the cancel is interrupted.

Common situations: Killing a running DataX task from the UI; worker shutdown/cancel during task execution; task process already exited concurrently so cancel races with process termination.

Related errors


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