{"record":{"id":"f2aa67787fc71522","repo":"apache/seatunnel","slug":"taskfullname-reset-state-failed-only-end-state","errorCode":null,"errorMessage":"${taskFullName} reset state failed, only end state can be reset, current is ${executionState}","messagePattern":"(.+?) reset state failed, only end state can be reset, current is (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java","lineNumber":495,"sourceCode":"        }\n        stateTimestamps[targetState.ordinal()] = System.currentTimeMillis();\n        runningJobStateTimestampsIMap.set(taskGroupLocation, stateTimestamps);\n    }\n\n    public ExecutionState getExecutionState() {\n        return currExecutionState;\n    }\n\n    private void resetExecutionState() {\n        synchronized (this) {\n            ExecutionState executionState = getExecutionState();\n            if (!executionState.isEndState()) {\n                String message =\n                        String.format(\n                                \"%s reset state failed, only end state can be reset, current is %s\",\n                                getTaskFullName(), executionState);\n                log.error(message);\n                throw new IllegalStateException(message);\n            }\n            try {\n                RetryUtils.retryWithException(\n                        () -> {\n                            updateStateTimestamps(ExecutionState.CREATED);\n                            runningJobStateIMap.set(taskGroupLocation, ExecutionState.CREATED);\n                            // reset the errorByPhysicalVertex\n                            errorByPhysicalVertex = new AtomicReference<>();\n                            return null;\n                        },\n                        new RetryUtils.RetryMaterial(\n                                Constant.OPERATION_RETRY_TIME,\n                                true,\n                                ExceptionUtil::isOperationNeedRetryException,\n                                Constant.OPERATION_RETRY_SLEEP));\n            } catch (Exception e) {\n                log.warn(ExceptionUtils.getMessage(e));\n                // If master/worker node done, The job will restore and fix the state from","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalVertex.java#L477-L513","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wait until all tasks reach a terminal state before restoring/resetting the job","Cancel the job fully (wait for JobResult) and only then invoke reset","Check each pipeline/task state via logs or REST API before calling reset","If the state is stuck in a non-terminal value (e.g. CANCELING forever), investigate hung tasks and force cleanup before reset"],"exampleFix":"// before\nplan.reset(); // called while tasks still CANCELING\n// after\njobClient.waitForJobCompletion(jobId); // ensure end state\nplan.reset();","handlingStrategy":"validation","validationCode":"if (!vertex.getExecutionState().isEndState()) { throw new IllegalStateException(\"cannot reset: task not in end state\"); }","typeGuard":"boolean canReset(ExecutionState s) { return s.isEndState(); }","tryCatchPattern":"try { vertex.reset(); } catch (IllegalStateException e) { if (e.getMessage().contains(\"only end state can be reset\")) { /* wait for completion, then retry */ } else { throw e; } }","preventionTips":["Only restore/reset jobs after all tasks terminate","Wait for JobResult after cancel","Detect stuck transitional states before reset"],"tags":["zeta-engine","task-state","reset","state-machine"],"backgroundTag":"invalid-state-transition","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}