{"record":{"id":"ff43713571a47816","repo":"apache/druid","slug":"spec-s-is-in-an-invalid-state-s","errorCode":null,"errorMessage":"spec[%s] is in an invalid state[%s]","messagePattern":"spec\\[(.+?)\\] is in an invalid state\\[(.+?)\\]","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexPhaseRunner.java","lineNumber":196,"sourceCode":"              } else {\n                // We have more subTasks to run, but don't have enough available task slots\n                // do nothing\n              }\n              break;\n            case FAILED:\n              // TaskMonitor already tried everything it can do for failed tasks. We failed.\n              state = TaskState.FAILED;\n              subTaskScheduleAndMonitorStopped = true;\n              final TaskStatusPlus lastStatus = taskCompleteEvent.getLastStatus();\n              if (lastStatus != null) {\n                LOG.error(\"Failed because of the failed sub task[%s]\", lastStatus.getId());\n              } else {\n                final SubTaskSpec<?> spec = taskCompleteEvent.getSpec();\n                LOG.error(\"Failed to process spec[%s] with an unknown last status\", spec.getId());\n              }\n              break;\n            default:\n              throw new ISE(\"spec[%s] is in an invalid state[%s]\", taskCompleteEvent.getSpec().getId(), completeState);\n          }\n        }\n      }\n    }\n    finally {\n      stopInternal();\n      if (!state.isComplete()) {\n        state = TaskState.FAILED;\n      }\n    }\n\n    return state;\n  }\n\n  private class CountingSubTaskSpecIterator implements Iterator<SubTaskSpec<SubTaskType>>\n  {\n    private final Iterator<SubTaskSpec<SubTaskType>> delegate;\n    private int count;","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexPhaseRunner.java#L178-L214","documentation":"Thrown from the default branch of the switch over the subtask's final TaskState in ParallelIndexPhaseRunner.run. Only SUCCESS and FAILED are expected; any other state (e.g. RUNNING, WAITING) on a completion event is treated as a bug in completion reporting.","triggerScenarios":"A task completion event is delivered whose lastState is not SUCCESS or FAILED — an inconsistent TaskStatusPlus from the overlord, or an enum value added later being routed through old runner logic.","commonSituations":"Corrupted or partially-written task status records after a crash; mixing Druid versions between overlord and middle managers where TaskState semantics differ; custom task runner extensions emitting non-terminal states.","solutions":["Query the overlord for the subtask's real final status to understand what state was reported.","Restart/resubmit the parallel index task; this is normally a one-off inconsistent event.","Align Druid versions across the cluster (overlord, middle managers, indexers).","Report/fix any extension that emits completion events with non-terminal states."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (ISE e) {\n  if (e.getMessage().contains(\"is in an invalid state\")) {\n    // query overlord for real final task status and resubmit\n  }\n}","preventionTips":["Run consistent Druid versions cluster-wide","Avoid non-standard task runner extensions","Resubmit the task after one-off status corruption"],"tags":["parallel-ingestion","task-state","internal-state"],"backgroundTag":"invalid-enum-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}