apache/hadoop · error · YarnRuntimeException

Unrecognized task state: {}

Error message

Unrecognized task state: {}

What it means

TypeConverter.fromYarn(TaskState) converts MRv2 task states into the classic TIPStatus (NEW/SCHEDULED→PENDING, RUNNING, KILLED, SUCCEEDED→COMPLETE, FAILED→FAILED) and throws YarnRuntimeException for any other constant. Like the sibling converters, all current TaskState values are covered; an unknown one means the value crossed a version boundary this jar cannot handle.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/TypeConverter.java:421

    throw new YarnRuntimeException("Unrecognized job state: " + state);
  }

  public static org.apache.hadoop.mapred.TIPStatus fromYarn(
      TaskState state) {
    switch (state) {
    case NEW:
    case SCHEDULED:
      return org.apache.hadoop.mapred.TIPStatus.PENDING;
    case RUNNING:
      return org.apache.hadoop.mapred.TIPStatus.RUNNING;
    case KILLED:
      return org.apache.hadoop.mapred.TIPStatus.KILLED;
    case SUCCEEDED:
      return org.apache.hadoop.mapred.TIPStatus.COMPLETE;
    case FAILED:
      return org.apache.hadoop.mapred.TIPStatus.FAILED;
    }
    throw new YarnRuntimeException("Unrecognized task state: " + state);
  }

  public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) {
    String[] diagnostics = null;
    if (report.getDiagnosticsList() != null) {
      diagnostics = new String[report.getDiagnosticsCount()];
      int i = 0;
      for (String cs : report.getDiagnosticsList()) {
        diagnostics[i++] = cs.toString();
      }
    } else {
      diagnostics = new String[0];
    }

    TaskReport rep = new TaskReport(fromYarn(report.getTaskId()),
        report.getProgress(), report.getTaskState().toString(),
      diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(),
      fromYarn(report.getCounters()));

View on GitHub (pinned to 2add963021)

Solutions

  1. Match client jar version to the producing server
  2. Treat unknown states as non-terminal (skip the report) instead of failing the caller
  3. Catch YarnRuntimeException around report conversion loops
Defensive patterns

Strategy: type-guard

Validate before calling

private static final Set<TaskState> KNOWN_TASK_STATES = EnumSet.range(
    TaskState.NEW, TaskState.SUCCEEDED); // adjust to your build's enum
if (!KNOWN_TASK_STATES.contains(taskState)) { /* skip report */ }

Type guard

static boolean isMappableTaskState(TaskState s) {
  return s == TaskState.NEW || s == TaskState.SCHEDULED || s == TaskState.RUNNING
      || s == TaskState.SUCCEEDED || s == TaskState.FAILED || s == TaskState.KILLED;
}

Try / catch

try {
  tipStatus = TypeConverter.fromYarn(taskState);
} catch (YarnRuntimeException e) {
  LOG.warn("Unknown task state {}; treating as PENDING", taskState);
  tipStatus = org.apache.hadoop.mapred.TIPStatus.PENDING;
}

Prevention

When it happens

Trigger: A task report whose TaskState is outside the handled set — from a newer server, a different Hadoop fork, or a synthetic record in tests.

Common situations: Version mismatch between client and cluster during/after upgrades; job-history replay tools reading newer history files; vendor distributions with extended states.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/739e34bc5df331f7. Report an issue: GitHub.