apache/dolphinscheduler · error · AliyunServerlessSparkTaskException
Failed to cancel job run!
Error message
Failed to cancel job run!
What it means
During cancelApplication, the task wraps any exception from cancelJobRun into AliyunServerlessSparkTaskException with this message. The kill/cancel request against the Aliyun Serverless Spark job run failed and the job may keep running.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-aliyunserverlessspark/src/main/java/org/apache/dolphinscheduler/plugin/task/aliyunserverlessspark/AliyunServerlessSparkTask.java:227
}
}
@Override
public AbstractParameters getParameters() {
return aliyunServerlessSparkParameters;
}
@Override
public void cancelApplication() throws TaskException {
CancelJobRunRequest cancelJobRunRequest = buildCancelJobRunRequest();
RetryUtils.retryFunction(
() -> {
try {
return aliyunServerlessSparkClient.cancelJobRun(
aliyunServerlessSparkParameters.getWorkspaceId(), jobRunId,
cancelJobRunRequest);
} catch (Exception e) {
throw new AliyunServerlessSparkTaskException("Failed to cancel job run! ", e);
}
}, retryPolicy);
}
@Override
public List<String> getApplicationIds() throws TaskException {
return Collections.emptyList();
}
protected Client buildAliyunServerlessSparkClient(String accessKeyId, String accessKeySecret,
String regionId, String endpoint) throws Exception {
if (StringUtils.isEmpty(endpoint)) {
endpoint = String.format(AliyunServerlessSparkConstants.ENDPOINT_TEMPLATE, regionId);
}
Config config = new Config()
.setEndpoint(endpoint)
.setAccessKeyId(accessKeyId)View on GitHub (pinned to 02eac45a1b)
Solutions
- Check the wrapped cause: 'invalid state' means the job already finished and can be ignored
- Verify workspaceId/jobRunId and that the job run is in a cancellable state
- Grant the AK/SK CancelJobRun permission
- Retry cancel or manually kill the job in the Aliyun console
Defensive patterns
Strategy: try-catch
Validate before calling
// check job run state before cancelling
GetJobRunResponse resp = client.getJobRun(workspaceId, jobRunId, new GetJobRunRequest());
String state = resp.getBody().getJobRun().getState();
boolean cancellable = !("COMPLETED".equals(state) || "FAILED".equals(state) || "CANCELLED".equals(state)); Try / catch
try {
task.cancelApplication();
} catch (TaskException e) {
log.warn("Cancel failed (job may already be terminal): {}", e.getMessage(), e);
} Prevention
- Check the job run state before cancelling
- Grant CancelJobRun permission to the credentials
- Expect cancel races with job completion; treat as benign
- Manually verify in the Aliyun console after a failed cancel
When it happens
Trigger: aliyunServerlessSparkClient.cancelJobRun(workspaceId, jobRunId, cancelJobRunRequest) throws — job run already in a terminal state, invalid workspaceId/jobRunId, auth failure, or network error while the user kills the task.
Common situations: User clicks 'kill' in DolphinScheduler after the job already finished (cancel on terminal state is rejected); credentials lack CancelJobRun permission; the jobRunId was garbage-collected; Aliyun API throttling during cancellation.
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
- Failed to get job run!
- Aliyun-Serverless-Spark task parameters are not valid!
- Failed to build Aliyun-Serverless-Spark client!
- Failed to get template info
- Failed to start job run!
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/57eee9f177b01123.
Report an issue: GitHub.