apache/seatunnel · error · IllegalStateException

${taskFullName} reset state failed, only end state can be re

Error message

${taskFullName} reset state failed, only end state can be reset, current is ${executionState}

What it means

PhysicalVertex.resetExecutionState only allows resetting a task group whose ExecutionState is an end state (FINISHED, FAILED, CANCELED, etc.), because reset rewinds state to CREATED for a job restore. If the vertex is still running or transitioning, resetting would corrupt the state machine, so an IllegalStateException is thrown.

Source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java:495

        }
        stateTimestamps[targetState.ordinal()] = System.currentTimeMillis();
        runningJobStateTimestampsIMap.set(taskGroupLocation, stateTimestamps);
    }

    public ExecutionState getExecutionState() {
        return currExecutionState;
    }

    private void resetExecutionState() {
        synchronized (this) {
            ExecutionState executionState = getExecutionState();
            if (!executionState.isEndState()) {
                String message =
                        String.format(
                                "%s reset state failed, only end state can be reset, current is %s",
                                getTaskFullName(), executionState);
                log.error(message);
                throw new IllegalStateException(message);
            }
            try {
                RetryUtils.retryWithException(
                        () -> {
                            updateStateTimestamps(ExecutionState.CREATED);
                            runningJobStateIMap.set(taskGroupLocation, ExecutionState.CREATED);
                            // reset the errorByPhysicalVertex
                            errorByPhysicalVertex = new AtomicReference<>();
                            return null;
                        },
                        new RetryUtils.RetryMaterial(
                                Constant.OPERATION_RETRY_TIME,
                                true,
                                ExceptionUtil::isOperationNeedRetryException,
                                Constant.OPERATION_RETRY_SLEEP));
            } catch (Exception e) {
                log.warn(ExceptionUtils.getMessage(e));
                // If master/worker node done, The job will restore and fix the state from

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Wait until all tasks reach a terminal state before restoring/resetting the job
  2. Cancel the job fully (wait for JobResult) and only then invoke reset
  3. Check each pipeline/task state via logs or REST API before calling reset
  4. If the state is stuck in a non-terminal value (e.g. CANCELING forever), investigate hung tasks and force cleanup before reset

Example fix

// before
plan.reset(); // called while tasks still CANCELING
// after
jobClient.waitForJobCompletion(jobId); // ensure end state
plan.reset();
Defensive patterns

Strategy: validation

Validate before calling

if (!vertex.getExecutionState().isEndState()) { throw new IllegalStateException("cannot reset: task not in end state"); }

Type guard

boolean canReset(ExecutionState s) { return s.isEndState(); }

Try / catch

try { vertex.reset(); } catch (IllegalStateException e) { if (e.getMessage().contains("only end state can be reset")) { /* wait for completion, then retry */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling PhysicalVertex.reset on a job whose task vertex has not reached a terminal state; restoring/resubmitting a job while some tasks are still RUNNING, FAILING, or CANCELING.

Common situations: User resubmits a savepointed/restored job before all pipelines finished cancelling; job restore triggered after partial failure while tasks are mid-shutdown; race between cancel completion and reset invocation.

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/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/f2aa67787fc71522. Report an issue: GitHub.