{"record":{"id":"7df20a51f008f1ea","repo":"apache/druid","slug":"can-t-find-surrogate-task-s","errorCode":null,"errorMessage":"Can't find surrogate task[%s]","messagePattern":"Can't find surrogate task\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SurrogateAction.java","lineNumber":72,"sourceCode":"  public ActionType getTaskAction()\n  {\n    return taskAction;\n  }\n\n  @Override\n  public TypeReference<ReturnType> getReturnTypeReference()\n  {\n    return taskAction.getReturnTypeReference();\n  }\n\n  @Override\n  public ReturnType perform(Task task, TaskActionToolbox toolbox)\n  {\n    final Optional<Task> maybeSurrogateTask = toolbox.getTaskStorage().getTask(surrogateId);\n    if (maybeSurrogateTask.isPresent()) {\n      return taskAction.perform(maybeSurrogateTask.get(), toolbox);\n    } else {\n      throw new ISE(\"Can't find surrogate task[%s]\", surrogateId);\n    }\n  }\n\n  @Override\n  public String toString()\n  {\n    return \"SurrogateAction{\" +\n           \"surrogateId='\" + surrogateId + '\\'' +\n           \", taskAction=\" + taskAction +\n           '}';\n  }\n}\n","sourceCodeStart":54,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/actions/SurrogateAction.java#L54-L85","documentation":"SurrogateAction delegates a TaskAction to a 'surrogate' task identified by surrogateId (e.g. when a supervisor-like task performs actions on behalf of another task). Before delegating, it looks the surrogate task up in task storage; if no task with that ID exists in storage, it throws this IllegalStateException. This is an internal consistency check: the caller referenced a task ID that the overlord has no record of.","triggerScenarios":"Submitting a surrogate TaskAction whose surrogateId refers to a task that was never created, has been killed/pruned from task storage, or whose ID was mistyped. Also occurs if the surrogate task completed and was removed before the delegating action ran.","commonSituations":"Overlord task storage cleaned up (e.g. kill tasks / short retention) while dependent tasks still reference old surrogate IDs; race between surrogate task completion and a queued action; bugs in custom task code forwarding wrong IDs after upgrades.","solutions":["Check that the surrogate task ID actually exists: query the overlord /druid/indexer/v1/tasks or task storage DB for the ID in the message.","Re-run or resubmit the parent task so a fresh surrogate task is created before its actions are performed.","If task cleanup is killing tasks too aggressively, increase task retention (keepAlive / kill task config) so dependent actions finish first.","Verify custom code isn't fabricating or truncating surrogate task IDs; upgrade if this is a known Druid bug."],"exampleFix":"// before\nTaskActionClient client = toolbox.getTaskActionClient();\nclient.submit(new SurrogateAction<>(someStaleId, new LockListAction()));\n// after\nif (toolbox.getTaskStorage().getTask(surrogateId).isPresent()) {\n  client.submit(new SurrogateAction<>(surrogateId, new LockListAction()));\n} else {\n  LOG.warn(\"surrogate task %s no longer exists, skipping\", surrogateId);\n}","handlingStrategy":"validation","validationCode":"Optional<Task> surrogate = toolbox.getTaskStorage().getTask(surrogateId);\nif (!surrogate.isPresent()) {\n  throw new IllegalStateException(\"Surrogate task \" + surrogateId + \" does not exist; resubmit the parent task\");\n}","typeGuard":"boolean surrogateExists(String id, TaskStorage storage) {\n  return storage.getTask(id).isPresent();\n}","tryCatchPattern":"try {\n  return actionClient.submit(new SurrogateAction<>(surrogateId, action));\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Can't find surrogate task\")) {\n    // recreate/resubmit the parent task, then retry\n  } else throw e;\n}","preventionTips":["Always create the surrogate task before submitting surrogate actions on its behalf.","Don't kill or prune tasks while dependent delegating actions may still run.","Log and verify surrogate task IDs when building custom delegation logic."],"tags":["indexing-service","task-storage","state"],"backgroundTag":"entity-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}