apache/dolphinscheduler · error · TaskException

cancel application error

Error message

cancel application error

What it means

SagemakerTask.cancelApplication() resolves the stored pipeline id and calls utils.stopPipelineExecution(); any exception is rethrown as TaskException("cancel application error", e). It means the AWS StopPipelineExecution call failed when the user tried to kill the running SageMaker task.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-sagemaker/src/main/java/org/apache/dolphinscheduler/plugin/task/sagemaker/SagemakerTask.java:134

            // Start pipeline
            pipelineId = utils.startPipelineExecution(client, request);

            // set AppId
            setAppIds(JSONUtils.toJsonString(pipelineId));
        } catch (Exception e) {
            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
            throw new TaskException("SageMaker task submit error", e);
        }
    }

    @Override
    public void cancelApplication() {
        initPipelineId();
        try {
            // stop pipeline
            utils.stopPipelineExecution(client, pipelineId);
        } catch (Exception e) {
            throw new TaskException("cancel application error", e);
        }
    }

    @Override
    public void trackApplicationStatus() throws TaskException {
        initPipelineId();
        // Keep checking the health status
        exitStatusCode = utils.checkPipelineExecutionStatus(client, pipelineId);
    }

    /**
     * init sagemaker applicationId if null
     */
    private void initPipelineId() {
        if (pipelineId == null) {
            if (StringUtils.isNotEmpty(getAppIds())) {
                pipelineId = JSONUtils.parseObject(getAppIds(), PipelineUtils.PipelineId.class);
            }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Inspect the cause chain: 'cannot be stopped' style AWS errors mean the pipeline already finished — the kill is harmless, verify final status instead.
  2. Grant sagemaker:StopPipelineExecution to the configured IAM identity.
  3. Verify AWS region/credentials on the datasource are still valid.
  4. Retry the kill; transient SDK failures may clear on a second attempt.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    task.cancelApplication();
} catch (TaskException e) {
    Throwable cause = e.getCause();
    if (cause != null && cause.getMessage().contains("cannot be stopped")) {
        log.info("Pipeline already finished; ignoring cancel failure");
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: utils.stopPipelineExecution(client, pipelineId) throws: pipeline already in a terminal state (cannot be stopped), insufficient IAM permissions, wrong region/credentials, or transient SDK/network errors.

Common situations: Killing a task whose pipeline already SUCCEEDED/FAILED (AWS refuses StopPipelineExecution on finished executions), IAM user lacking sagemaker:StopPipelineExecution, credentials rotated between submit and cancel.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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