{"record":{"id":"d24ba876a60ec35f","repo":"apache/druid","slug":"expected-s-but-s-is-in-use","errorCode":null,"errorMessage":"Expected [%s], but [%s] is in use","messagePattern":"Expected \\[(.+?)\\], but \\[(.+?)\\] is in use","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTask.java","lineNumber":1404,"sourceCode":"   */\n  @POST\n  @Path(\"/segment/allocate\")\n  @Produces(SmileMediaTypes.APPLICATION_JACKSON_SMILE)\n  @Consumes(SmileMediaTypes.APPLICATION_JACKSON_SMILE)\n  public Response allocateSegment(\n      Object param,\n      @Context final HttpServletRequest req\n  )\n  {\n    ChatHandlers.authorizationCheck(req, Action.READ, getDataSource(), authorizerMapper);\n\n    if (toolbox == null) {\n      return Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(\"task is not running yet\").build();\n    }\n\n    ParallelIndexTaskRunner runner = Preconditions.checkNotNull(getCurrentRunner(), \"runner\");\n    if (!(runner instanceof SinglePhaseParallelIndexTaskRunner)) {\n      throw new ISE(\n          \"Expected [%s], but [%s] is in use\",\n          SinglePhaseParallelIndexTaskRunner.class.getName(),\n          runner.getClass().getName()\n      );\n    }\n\n    // This context is set in the constructor of ParallelIndexSupervisorTask if it's not set by others.\n    final boolean useLineageBasedSegmentAllocation = Preconditions.checkNotNull(\n        getContextValue(SinglePhaseParallelIndexTaskRunner.CTX_USE_LINEAGE_BASED_SEGMENT_ALLOCATION_KEY),\n        \"useLineageBasedSegmentAllocation in taskContext\"\n    );\n\n    try {\n      final SegmentIdWithShardSpec segmentIdentifier;\n      if (useLineageBasedSegmentAllocation) {\n        SegmentAllocationRequest request = toolbox.getJsonMapper().convertValue(param, SegmentAllocationRequest.class);\n        segmentIdentifier = ((SinglePhaseParallelIndexTaskRunner) runner)\n            .allocateNewSegment(","sourceCodeStart":1386,"sourceCodeEnd":1422,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTask.java#L1386-L1422","documentation":"Thrown by an HTTP endpoint on ParallelIndexSupervisorTask (e.g. the /subtaskspecs or related REST API) when the currently active runner is not a SinglePhaseParallelIndexTaskRunner. Those endpoints only make sense for single-phase parallel ingestion; calling them on a task running a different runner is an invalid request.","triggerScenarios":"Hitting task REST endpoints like /druid/indexer/v1/task/{id}/subtaskspecs or /unparseableEvents (subtask spec APIs) against a task whose runner is a two-phase/sequential runner (e.g. runTask via SQL-generated replace tasks).","commonSituations":"Scripts or UI integrations that query subtask APIs for every batch task regardless of its type; monitoring tools pointing at compaction or MSQ replace tasks that use other runners.","solutions":["Only call subtask-spec endpoints on tasks using SinglePhaseParallelIndexTaskRunner; check the task type first.","For multi-phase tasks use the appropriate endpoints (/subtaskspecs vs phase-specific APIs) or the overlord task report.","Update monitoring scripts to branch on task 'type' (index_parallel vs index/replace)."],"exampleFix":"// before\ncurl $OVERLORD/druid/indexer/v1/task/$taskId/subtaskspecs\n// after: only for index_parallel tasks\ntype=$(curl $OVERLORD/druid/indexer/v1/task/$taskId | jq -r .payload.type)\nif [ \"$type\" = \"index_parallel\" ]; then\n  curl $OVERLORD/druid/indexer/v1/task/$taskId/subtaskspecs\nfi","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function canQuerySubtaskSpecs(taskType) {\n  return taskType === 'index_parallel';\n}","tryCatchPattern":null,"preventionTips":["Check task 'type' before calling subtask-spec REST endpoints","Branch monitoring scripts on task type (index_parallel vs index/replace)","Handle HTTP 500 with the 'Expected [%s], but [%s] is in use' message as 'endpoint not applicable'"],"tags":["rest-api","wrong-task-type","parallel-ingestion"],"backgroundTag":"unsupported-operation","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"}