apache/hadoop · warning · NotFoundException

task not found with id {tid}

Error message

task not found with id {tid}

What it means

Returned as HTTP 404 by the JobHistoryServer REST task endpoints (e.g. getSingleTaskCounters) when the task id parsed successfully but job.getTask(taskID) returns null — the task does not exist within that job. The identifier is structurally valid but was never created by the job (wrong task number or wrong job embedded in the id).

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java:393

  @GET
  @Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/counters")
  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
  public JobTaskCounterInfo getSingleTaskCounters(
      @Context HttpServletRequest hsr, @PathParam("jobid") String jid,
      @PathParam("taskid") String tid) {

    init();
    Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
    checkAccess(job, hsr);
    TaskId taskID = MRApps.toTaskID(tid);
    if (taskID == null) {
      throw new NotFoundException("taskid " + tid + " not found or invalid");
    }
    Task task = job.getTask(taskID);
    if (task == null) {
      throw new NotFoundException("task not found with id " + tid);
    }
    return new JobTaskCounterInfo(task);
  }

  @GET
  @Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts")
  @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
      MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
  public TaskAttemptsInfo getJobTaskAttempts(@Context HttpServletRequest hsr,
      @PathParam("jobid") String jid, @PathParam("taskid") String tid) {

    init();
    TaskAttemptsInfo attempts = new TaskAttemptsInfo();
    Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
    checkAccess(job, hsr);
    Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
    for (TaskAttempt ta : task.getAttempts().values()) {
      if (ta != null) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Fetch the task list (GET .../tasks) and verify the exact id exists before requesting counters/attempts
  2. Ensure the jobid path segment and the job portion of the taskid string match
  3. Refresh any cached task ids after job reruns

Example fix

# before
curl "http://jhs:19888/ws/v1/history/mapreduce/jobs/$JID/tasks/task_1400000000000_0001_m_999/counters" # 404

# after
ids=$(curl -s "http://jhs:19888/ws/v1/history/mapreduce/jobs/$JID/tasks" | jq -r '.tasks.task[].id')
echo "$ids" | grep task_1400000000000_0001_m_ # pick a real id, then fetch counters
Defensive patterns

Strategy: validation

Validate before calling

Set<String> known = jhsClient.listTaskIds(jid); // GET .../tasks
if (!known.contains(tid)) {
  // id is valid-shaped but absent: refresh listing or fail with context
}

Try / catch

try { info = jhsClient.getTaskCounters(jid, tid); }
catch (NotFoundException e) {
  if (e.getMessage().contains("task not found with id"))
    tid = resolveFreshTaskId(jid); // re-list and remap
}

Prevention

When it happens

Trigger: GET /ws/v1/history/mapreduce/jobs/job_1400000000000_0001/tasks/task_1400000000000_0001_m_999/counters where the job launched fewer than 1000 map tasks; also when the id's job portion refers to another job.

Common situations: Off-by-one when iterating task numbers discovered from a different source; Using an id from a retry/rerun of the job (new job id, different task numbering); Stale cached ids in a dashboard after the job was rerun

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 apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/5f4dac907a25cc3c. Report an issue: GitHub.