{"record":{"id":"c07cb87fab1234e0","repo":"apache/dolphinscheduler","slug":"execute-emr-task-failed","errorCode":null,"errorMessage":"Execute emr task failed","messagePattern":"Execute emr task failed","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java","lineNumber":114,"sourceCode":"            setExitStatusCode(exitStatusCode);\n            log.info(\"emr task finished with step status : {}\", stepStatus);\n        }\n    }\n\n    @Override\n    public void trackApplicationStatus() throws TaskException {\n        StepStatus stepStatus = getStepStatus();\n\n        try {\n            while (waitingStateSet.contains(stepStatus.getState())) {\n                TimeUnit.SECONDS.sleep(10);\n                stepStatus = getStepStatus();\n            }\n        } catch (EmrTaskException | SdkBaseException e) {\n            log.error(\"emr task failed with error\", e);\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new TaskException(\"Execute emr task failed\", e);\n        } finally {\n            final int exitStatusCode = calculateExitStatusCode(stepStatus);\n            setExitStatusCode(exitStatusCode);\n            log.info(\"emr task finished with step status : {}\", stepStatus);\n        }\n    }\n\n    /**\n     * parse json string to AddJobFlowStepsRequest\n     *\n     * @return AddJobFlowStepsRequest\n     */\n    protected AddJobFlowStepsRequest createAddJobFlowStepsRequest() {\n\n        final AddJobFlowStepsRequest addJobFlowStepsRequest;\n        String jobStepDefineJson = null;\n        try {\n            jobStepDefineJson = ParameterUtils.convertParameterPlaceholders(","sourceCodeStart":96,"sourceCodeEnd":132,"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#L96-L132","documentation":"EmrAddStepsTask.trackApplicationStatus polls ListSteps/DescribeStep for step completion. SdkBaseException and EmrTaskException during polling are only logged (task continues with last-known stepStatus), but an InterruptedException is rethrown as TaskException 'Execute emr task failed' after restoring the interrupt flag. This signals the polling thread was interrupted — normally a task kill or worker shutdown.","triggerScenarios":"Thread.interrupt() while the polling loop sleeps between step-status checks — workflow stop/kill, worker shutdown, or timeout-based cancellation by the scheduler.","commonSituations":"User kills a long-running EMR step workflow; worker drain during deployment; retry/timeout policy interrupts the tracker. The EMR step itself keeps running in AWS unless the step's ActionOnFailure/cancel handling stops it.","solutions":["Expected on kill — verify the exit status handling in finally recorded the correct state and cancel orphaned EMR steps if needed","If unexpected, check worker logs for shutdown or kill events at that timestamp","Adjust task timeout so long steps are not interrupted by scheduler timeouts","For step cleanup on kill, use the EMR console/AWS CLI to cancel pending steps of the cluster"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    task.trackApplicationStatus();\n} catch (TaskException e) {\n    if (e.getCause() instanceof InterruptedException) {\n        log.warn(\"EMR tracking interrupted (kill/shutdown); step may still run in AWS\");\n        // follow up: cancel pending steps via emrClient.cancelSteps if needed\n    } else {\n        throw e;\n    }\n}","preventionTips":["Set workflow/task timeouts above the longest expected EMR step duration","On kill, cancel outstanding EMR steps (emr cancel-steps) to avoid orphaned work","Use ActionOnFailure=TERMINATE_CLUSTER to bound step runtimes on failure","Schedule worker deployments outside heavy EMR job windows to reduce drain interruptions"],"tags":["aws","emr","interruption","polling"],"backgroundTag":"request-timeout","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"}