apache/dolphinscheduler · error · IllegalStateException

"The task: " + taskExecution.getName() + " state: " + taskIn

Error message

"The task: " + taskExecution.getName() + " state: " + taskInstance.getState() + " is not " + taskExecutionStatus

What it means

Thrown by WorkflowExecutionGraph.assertTaskExecutionState when a task instance's state does not match the expected TaskExecutionStatus during chain failure/pause/kill marking. The graph enforces that these state transitions only apply to tasks already in the expected state; a mismatch means concurrent state change or an out-of-order event. It surfaces as IllegalStateException.

Source

Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowExecutionGraph.java:349

    @Override
    public boolean isAllSuccessorsAreConditionTask(final ITaskExecution taskExecution) {
        final List<ITaskExecution> successors = getSuccessors(taskExecution.getName());
        if (CollectionUtils.isEmpty(successors)) {
            return false;
        }
        return successors.stream().allMatch(
                successor -> isTaskExecutionSkipped(successor)
                        || (TaskTypeUtils.isConditionTask(successor.getTaskDefinition().getTaskType())
                                && !isTaskExecutionForbidden(successor)));
    }

    private void assertTaskExecutionState(final ITaskExecution taskExecution,
                                          final TaskExecutionStatus taskExecutionStatus) {
        final TaskInstance taskInstance = taskExecution.getTaskInstance();
        if (taskInstance.getState() == taskExecutionStatus) {
            return;
        }
        throw new IllegalStateException(
                "The task: " + taskExecution.getName() + " state: " + taskInstance.getState() + " is not "
                        + taskExecutionStatus);
    }

}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the task instance's current state before issuing pause/kill/failure chain operations and skip if it already advanced.
  2. Serialize pause/kill requests through the master to avoid racing with task completion events.
  3. If seen during failover, resync task states from the DB before replaying chain operations.

Example fix

// before: blind chain kill
graph.markTaskExecutionChainKill(taskExecution);
// after: check state first
if (taskExecution.getTaskInstance().getState() == TaskExecutionStatus.KILL) {
    return;
}
graph.markTaskExecutionChainKill(taskExecution);
Defensive patterns

Strategy: validation

Validate before calling

// verify state before chain operations
if (taskExecution.getTaskInstance().getState() != expectedStatus) {
    return; // already advanced; skip chain failure/pause/kill
}
graph.markTaskExecutionChainKill(taskExecution);

Type guard

boolean inExpectedState(ITaskExecution t, TaskExecutionStatus expected) {
    return t.getTaskInstance().getState() == expected;
}

Try / catch

try {
    graph.markTaskExecutionChainKill(taskExecution);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("The task:") && e.getMessage().contains("is not")) {
        // state advanced concurrently; log and continue
    } else throw e;
}

Prevention

When it happens

Trigger: markTaskExecutionChainFailure/Pause/Kill invoked for a task whose TaskInstance.getState() differs from the expected status — e.g. the task already moved to KILL by another path, or a pause arrives after the task finished.

Common situations: Race between user pause/kill actions and task completion; duplicate master events processed twice; failover scenarios where the new master sees states the old one already advanced.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/8f9c7a5fe17a9ed8. Report an issue: GitHub.