apache/dolphinscheduler · error · EmrTaskException
cancel emr step failed, message:${cancelEmrStepInfo.getReaso
Error message
cancel emr step failed, message:${cancelEmrStepInfo.getReason()} What it means
Semantic guard in cancelApplication: the CancelStepsResult was returned, but its embedded CancelStepsInfo reports the cancellation was NOT accepted — AWS rejected the cancel (e.g. the step is already in a terminal state) with a reason string interpolated into the message. The offending input is the AWS-returned cancelEmrStepInfo reason.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:206
@Override
public void cancelApplication() throws TaskException {
log.info("trying cancel emr step, taskId:{}, clusterId:{}, stepId:{}",
this.taskExecutionContext.getTaskInstanceId(), clusterId, stepId);
CancelStepsRequest cancelStepsRequest = new CancelStepsRequest().withClusterId(clusterId).withStepIds(stepId);
CancelStepsResult cancelStepsResult = emrClient.cancelSteps(cancelStepsRequest);
if (cancelStepsResult == null) {
throw new EmrTaskException("cancel emr step failed");
}
CancelStepsInfo cancelEmrStepInfo = cancelStepsResult.getCancelStepsInfoList()
.stream()
.filter(cancelStepsInfo -> cancelStepsInfo.getStepId().equals(stepId))
.findFirst()
.orElseThrow(() -> new EmrTaskException("cancel emr step failed"));
if (CancelStepsRequestStatus.FAILED.toString().equals(cancelEmrStepInfo.getStatus())) {
throw new EmrTaskException("cancel emr step failed, message:" + cancelEmrStepInfo.getReason());
}
log.info("the result of cancel emr step is:{}", cancelStepsResult);
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Read the interpolated reason — typically the step already completed/failed/cancelled, in which case no action is needed
- Track the step's terminal status instead of re-issuing cancel when the step is already terminal
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:206 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/4788aab253ae72ff.
Report an issue: GitHub.