{"record":{"id":"7bf691a255a68584","repo":"apache/dolphinscheduler","slug":"emr-serverless-task-tracking-interrupted","errorCode":null,"errorMessage":"EMR Serverless task tracking interrupted","messagePattern":"EMR Serverless task tracking interrupted","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-emr-serverless/src/main/java/org/apache/dolphinscheduler/plugin/task/emrserverless/EmrServerlessTask.java","lineNumber":176,"sourceCode":"            }\n\n            String currentState = getJobRunState();\n            while (WAITING_STATES.contains(currentState)) {\n                TimeUnit.SECONDS.sleep(10);\n                currentState = getJobRunState();\n            }\n\n            final int exitCode = mapStateToExitCode(currentState);\n            setExitStatusCode(exitCode);\n            log.info(\"EMR Serverless job run [{}] finished with state: {}, exitCode: {}\",\n                    jobRunId, currentState, exitCode);\n\n        } catch (EmrServerlessTaskException | SdkBaseException e) {\n            log.error(\"EMR Serverless task tracking failed\", e);\n            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new TaskException(\"EMR Serverless task tracking interrupted\", e);\n        }\n    }\n\n    @Override\n    public void cancelApplication() throws TaskException {\n        if (StringUtils.isEmpty(jobRunId)) {\n            log.warn(\"jobRunId is empty, skip cancel\");\n            return;\n        }\n        log.info(\"Cancelling EMR Serverless job run, applicationId: {}, jobRunId: {}\",\n                emrServerlessParameters.getApplicationId(), jobRunId);\n        try {\n            CancelJobRunRequest request = new CancelJobRunRequest()\n                    .withApplicationId(emrServerlessParameters.getApplicationId())\n                    .withJobRunId(jobRunId);\n            CancelJobRunResult result = emrServerlessClient.cancelJobRun(request);\n            log.info(\"Cancel job run result: {}\", result);\n        } catch (SdkBaseException e) {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-emr-serverless/src/main/java/org/apache/dolphinscheduler/plugin/task/emrserverless/EmrServerlessTask.java#L158-L194","documentation":"The polling loop in trackApplicationStatus sleeps 10 seconds between GetJobRun calls; if that sleep is interrupted (thread interrupt), the plugin restores the interrupt flag and rethrows as a TaskException with this message. This is the plugin's cooperative-cancellation path — usually the workflow/task instance was killed or the worker is shutting down.","triggerScenarios":"Thread.interrupt() delivered while TimeUnit.SECONDS.sleep(10) is blocked inside the WAITING_STATES polling loop — a task kill, workflow stop, or worker shutdown.","commonSituations":"User clicks stop/kill on the running workflow instance; worker graceful shutdown drains running tasks; watchdog timeout interrupts the task thread.","solutions":["Expected behavior on kill — no code fix needed; the underlying AWS job run continues, so cancel it via cancelApplication or the AWS console if it should not finish","If unexpected, check worker logs for shutdown/kill events around the interruption time","If job runs should survive kills, monitor and cancel orphaned EMR Serverless job runs externally","Ensure task timeout settings align with expected job duration so the scheduler does not kill long-running jobs mid-poll"],"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(\"Tracking interrupted (task killed); AWS job run may still be active — cancel if needed\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Set realistic task timeouts longer than expected EMR job duration","On kill, follow up with cancelApplication or AWS CLI to stop the job run","Avoid ad-hoc Thread.interrupt on task threads unless kill is intended","Run long jobs with worker shutdown grace periods configured"],"tags":["aws","emr-serverless","interruption","task-kill"],"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"}