apache/seatunnel · error · IllegalStateException

${pipelineFullName} reset state failed, only end state can b

Error message

${pipelineFullName} reset state failed, only end state can be reset, current is ${pipelineState}

What it means

SubPlan.resetPipelineState only permits resetting a pipeline that has reached a terminal PipelineStatus, since reset rewinds it to CREATED for job restore. Resetting a running or transitioning pipeline would corrupt scheduling, so an IllegalStateException is thrown.

Source

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

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

    private void resetPipelineState() throws Exception {
        RetryUtils.retryWithException(
                () -> {
                    PipelineStatus pipelineState = getPipelineState();
                    if (!pipelineState.isEndState()) {
                        String message =
                                String.format(
                                        "%s reset state failed, only end state can be reset, current is %s",
                                        getPipelineFullName(), pipelineState);
                        log.error(message);
                        throw new IllegalStateException(message);
                    }
                    log.info(
                            String.format(
                                    "Reset pipeline %s state to %s",
                                    getPipelineFullName(), PipelineStatus.CREATED));
                    updateStateTimestamps(PipelineStatus.CREATED);
                    runningJobStateIMap.set(pipelineLocation, PipelineStatus.CREATED);
                    this.currPipelineStatus = PipelineStatus.CREATED;
                    log.info(
                            String.format(
                                    "Reset pipeline %s state to %s complete",
                                    getPipelineFullName(), PipelineStatus.CREATED));
                    return null;
                },
                new RetryUtils.RetryMaterial(
                        Constant.OPERATION_RETRY_TIME,
                        true,
                        exception -> ExceptionUtil.isOperationNeedRetryException(exception),

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Wait for all pipelines to reach an end state before calling reset
  2. Fully cancel the job and await its JobResult prior to restore/reset
  3. Check pipeline states in logs/REST API before invoking reset
  4. If a pipeline is stuck in a transitional state, find the hung task and force cleanup first

Example fix

// before
subPlan.reset(); // pipeline still CANCELING
// after
pipelineFuture.join(); // wait for PipelineExecutionState (end state)
subPlan.reset();
Defensive patterns

Strategy: validation

Validate before calling

if (!subPlan.getPipelineState().isEndState()) { throw new IllegalStateException("pipeline must be terminal before reset"); }

Type guard

boolean canResetPipeline(PipelineStatus s) { return s.isEndState(); }

Try / catch

try { subPlan.reset(); } catch (IllegalStateException e) { if (e.getMessage().contains("only end state can be reset")) { /* defer reset until shutdown completes */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling SubPlan.reset while the pipeline is RUNNING, SCHEDULED, FAILING, or CANCELING; restoring a job before all pipelines finished their shutdown.

Common situations: Resubmitting a savepoint-restore while pipelines are still cancelling; double-submit of the same job id; race between job restore and pipeline shutdown completion.

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/7fbc086631fa3d78. Report an issue: GitHub.