{"record":{"id":"be59c217583101c0","repo":"apache/dolphinscheduler","slug":"cancel-emr-step-failed","errorCode":null,"errorMessage":"cancel emr step failed","messagePattern":"cancel emr step failed","errorType":"exception","errorClass":"EmrTaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java","lineNumber":196,"sourceCode":"        DescribeStepResult result = emrClient.describeStep(describeStepRequest);\n        if (result == null) {\n            throw new EmrTaskException(\"fetch step status failed\");\n        }\n        StepStatus stepStatus = result.getStep().getStatus();\n        log.info(\"emr step [clusterId:{}, stepId:{}] running with status:{}\", clusterId, stepId, stepStatus);\n        return stepStatus;\n\n    }\n\n    @Override\n    public void cancelApplication() throws TaskException {\n        log.info(\"trying cancel emr step, taskId:{}, clusterId:{}, stepId:{}\",\n                this.taskExecutionContext.getTaskInstanceId(), clusterId, stepId);\n        CancelStepsRequest cancelStepsRequest = new CancelStepsRequest().withClusterId(clusterId).withStepIds(stepId);\n        CancelStepsResult cancelStepsResult = emrClient.cancelSteps(cancelStepsRequest);\n\n        if (cancelStepsResult == null) {\n            throw new EmrTaskException(\"cancel emr step failed\");\n        }\n\n        CancelStepsInfo cancelEmrStepInfo = cancelStepsResult.getCancelStepsInfoList()\n                .stream()\n                .filter(cancelStepsInfo -> cancelStepsInfo.getStepId().equals(stepId))\n                .findFirst()\n                .orElseThrow(() -> new EmrTaskException(\"cancel emr step failed\"));\n\n        if (CancelStepsRequestStatus.FAILED.toString().equals(cancelEmrStepInfo.getStatus())) {\n            throw new EmrTaskException(\"cancel emr step failed, message:\" + cancelEmrStepInfo.getReason());\n        }\n\n        log.info(\"the result of cancel emr step is:{}\", cancelStepsResult);\n    }\n\n}\n","sourceCodeStart":178,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java#L178-L213","documentation":"Sentinel guard in cancelApplication: emrClient.cancelSteps returned null (or the cancellation request itself was rejected), so the EMR step cancel cannot be confirmed. It is the AWS-side cancel path failing — SDK error, credentials, or the step/cluster already gone — distinct from the later guard that inspects CancelStepsInfo for an error reason.","triggerScenarios":"Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the caused-by AWS SDK exception for the concrete failure (auth, throttling, step not found)","Verify clusterId and stepId still reference a live cluster/step before cancelling","Retry cancellation after transient AWS errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}