prestodb/presto · warning · NotFoundException
TaskInfo not found for task id
Error message
TaskInfo not found for task id
What it means
getTaskInfo cannot locate TaskInfo for the requested task id on this node and throws a JAX-RS NotFoundException (HTTP 404). Tasks are short-lived and their info is retained only briefly, so lookups can legitimately miss.
Source
Thrown at presto-main/src/main/java/com/facebook/presto/server/TaskInfoResource.java:122
private TaskInfo getTaskInfo(TaskId taskId)
{
QueryId queryId = taskId.getQueryId();
try {
Optional<StageInfo> stageInfo = queryManager.getFullQueryInfo(queryId).getOutputStage();
if (stageInfo.isPresent()) {
Optional<StageInfo> stage = stageInfo.get().getStageWithStageId(taskId.getStageExecutionId().getStageId());
if (stage.isPresent()) {
Optional<TaskInfo> taskInfo = stage.get().getLatestAttemptExecutionInfo().getTasks().stream()
.filter(info -> info.getTaskId().equals(taskId))
.findFirst();
if (taskInfo.isPresent()) {
return taskInfo.get();
}
}
}
throw new NotFoundException("TaskInfo not found for task id " + taskId.toString());
}
catch (Exception e) {
throw new NotFoundException(e);
}
}
private boolean requestNeedsToBeProxied(TaskId taskId, boolean includeLocalQueryOnly)
{
return !includeLocalQueryOnly
&& resourceManagerEnabled
&& !dispatchManager.isQueryPresent(taskId.getQueryId());
}
private URI createTaskInfoUri(UriInfo uriInfo, InternalNode resourceManagerNode)
throws UnknownHostException
{
return UriBuilder.fromUri(uriInfo.getRequestUri())
.queryParam(INCLUDE_LOCAL_QUERY_ONLY, true)View on GitHub (pinned to 55bb57d202)
Solutions
- Retry against the coordinator, which routes task info requests to the correct node
- Refresh query/task state from the coordinator's query info instead of caching task IDs
- Handle 404 as 'task completed or never existed' in client logic rather than a hard failure
- Shorten the gap between getting the taskId and fetching its info in custom tooling
Example fix
// before
TaskInfo info = taskClient.getTaskInfo(taskId); // throws if gone
// after
Optional<TaskInfo> info = taskClient.getTaskInfoIfPresent(taskId);
if (!info.isPresent()) { refreshFromQueryInfo(queryId); } Defensive patterns
Strategy: try-catch
Validate before calling
// Check task/query still active via coordinator first: GET /v1/query/{queryId} — skip task fetch if state is FINISHED/FAILED Type guard
boolean isFetchableTaskId(TaskId taskId) { return taskId != null && !taskId.toString().isEmpty(); } Try / catch
try { return taskClient.getTaskInfo(taskId); } catch (NotFoundException e) { LOG.info("Task %s already completed or evicted", taskId); return Optional.empty(); } Prevention
- Treat 404 on task info as a normal terminal outcome in distributed queries
- Route task info requests through the coordinator, not directly at arbitrary nodes
- Avoid long-lived caching of TaskId references; refresh from query info
When it happens
Trigger: GET /v1/task/{taskId} (or the UI task info endpoint) for a taskId that never ran on this node, already finished and was evicted from SqlTaskManager, or the query was cancelled.
Common situations: Stale task references in client code or UI bookmarks after query completion, load balancer routing to a node that never owned the task, retries after a task was already cleaned up, split failures surfacing as missing tasks.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/7fce7ec75a540fee.
Report an issue: GitHub.