apache/hadoop · error · YarnRuntimeException

Unrecognized task type: {}

Error message

Unrecognized task type: {}

What it means

TypeConverter.fromYarn(TaskType) maps the MRv2 protocol enum to the old-API enum but only handles MAP and REDUCE — the two types the MR runtime actually creates task objects for — and throws YarnRuntimeException for anything else. It is defensive: with the current MRv2 enum the default is unreachable, so hitting it means the value came from a different (newer) protocol version or a synthetic record.

Source

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

  }

  private static String fromClusterTimeStamp(long clusterTimeStamp) {
    return Long.toString(clusterTimeStamp);
  }

  private static long toClusterTimeStamp(String identifier) {
    return Long.parseLong(identifier);
  }

  public static org.apache.hadoop.mapreduce.TaskType fromYarn(
      TaskType taskType) {
    switch (taskType) {
    case MAP:
      return org.apache.hadoop.mapreduce.TaskType.MAP;
    case REDUCE:
      return org.apache.hadoop.mapreduce.TaskType.REDUCE;
    default:
      throw new YarnRuntimeException("Unrecognized task type: " + taskType);
    }
  }

  public static TaskType
      toYarn(org.apache.hadoop.mapreduce.TaskType taskType) {
    switch (taskType) {
    case MAP:
      return TaskType.MAP;
    case REDUCE:
      return TaskType.REDUCE;
    default:
      throw new YarnRuntimeException("Unrecognized task type: " + taskType);
    }
  }

  public static org.apache.hadoop.mapred.TaskID fromYarn(TaskId id) {
    return new org.apache.hadoop.mapred.TaskID(fromYarn(id.getJobId()),
      fromYarn(id.getTaskType()), id.getId());

View on GitHub (pinned to 2add963021)

Solutions

  1. Match the hadoop-mapreduce-client-common version to the cluster (same Hadoop release on client and server)
  2. If you control the records, filter to MAP/REDUCE before conversion
  3. Catch YarnRuntimeException at the API boundary and degrade (skip the record, log the raw value)

Example fix

// before
org.apache.hadoop.mapreduce.TaskType t = TypeConverter.fromYarn(task.getType());

// after
if (task.getType() == TaskType.MAP || task.getType() == TaskType.REDUCE) {
  org.apache.hadoop.mapreduce.TaskType t = TypeConverter.fromYarn(task.getType());
} // else skip/report unknown kind
Defensive patterns

Strategy: type-guard

Validate before calling

TaskType t = yarnTask.getType();
if (t != TaskType.MAP && t != TaskType.REDUCE) {
  LOG.warn("Skipping non map/reduce task type {}", t); continue;
}

Type guard

static boolean isMappableTaskType(TaskType t) {
  return t == TaskType.MAP || t == TaskType.REDUCE;
}

Try / catch

try {
  oldType = TypeConverter.fromYarn(yarnType);
} catch (YarnRuntimeException e) {
  LOG.warn("Dropping task with unmapped type {}", yarnType);
  continue;
}

Prevention

When it happens

Trigger: A MRv2 protocol response (task reports, completion events) carrying a TaskType constant other than MAP/REDUCE — e.g. from a newer ResourceManager/MR AppMaster than the client jar; unit tests fabricating TaskId/TaskType records.

Common situations: Client jars older than the cluster (down-level mapreduce-client-common); rolling upgrades where the wire protocol gained a task-type constant; test fixtures using mock protocol records with unmapped values.

Related errors


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