apache/hadoop · error · IOException

Invalid resource name: {} specified.

Error message

Invalid resource name: {} specified.

What it means

When mapreduce.job.am.strict-locality (MRJobConfig.AM_STRICT_LOCALITY) pins the AM container, YARNRunner must interpret the value as either a rack (leading '/') or a node name resolved through RackResolver. It builds a rack request (and a node request with relaxLocality=false when a node name is resolved); if the value matches neither a resolvable node nor a rack, it logs a warning and throws IOException('Invalid resource name: ... specified.'), failing job submission.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java:787

          nodeName = matcher.group(NODE_IF_RACK_GROUP);
        }
        ResourceRequest amRackResourceRequest = rackRequests.get(rackName);
        if (amRackResourceRequest == null) {
          amRackResourceRequest = createAMResourceRequest(rackName, capability);
          amResourceRequests.add(amRackResourceRequest);
          rackRequests.put(rackName, amRackResourceRequest);
        }
        if (nodeName != null) {
          amRackResourceRequest.setRelaxLocality(false);
          ResourceRequest amNodeResourceRequest =
              createAMResourceRequest(nodeName, capability);
          amResourceRequests.add(amNodeResourceRequest);
        }
      } else {
        String errMsg =
            "Invalid resource name: " + amStrictResource + " specified.";
        LOG.warn(errMsg);
        throw new IOException(errMsg);
      }
    }
    if (LOG.isDebugEnabled()) {
      for (ResourceRequest amResourceRequest : amResourceRequests) {
        LOG.debug("ResourceRequest: resource = "
            + amResourceRequest.getResourceName() + ", locality = "
            + amResourceRequest.getRelaxLocality());
      }
    }
    return amResourceRequests;
  }

  private ResourceRequest createAMResourceRequest(String resource,
      Resource capability) {
    ResourceRequest resourceRequest =
        recordFactory.newRecordInstance(ResourceRequest.class);
    resourceRequest.setPriority(AM_CONTAINER_PRIORITY);
    resourceRequest.setResourceName(resource);

View on GitHub (pinned to 2add963021)

Solutions

  1. For a node, use the exact node name YARN reports (NodeManager host as shown in the RM UI / nodes REST endpoint) and verify RackResolver can resolve it from the client host
  2. For a rack, prefix the value with '/' (e.g. /default-rack)
  3. Unset mapreduce.job.am.strict-locality if strict AM placement is not actually required
  4. Check that the client's topology configuration (net.topology.script.file.name) matches the cluster's, so rack resolution agrees with the RM

Example fix

# before
<property><name>mapreduce.job.am.strict-locality</name><value>nod1.example.com</value></property>

# after
<property><name>mapreduce.job.am.strict-locality</name><value>node1.example.com</value></property>
# or for a rack
<property><name>mapreduce.job.am.strict-locality</name><value>/rack01</value></property>
Defensive patterns

Strategy: validation

Validate before calling

String strict = conf.get("mapreduce.job.am.strict-locality");
if (strict != null && !strict.isEmpty()) {
  if (strict.startsWith("/")) {
    // rack name: verify it exists in the cluster topology
  } else {
    List<Node> resolved = RackResolver.resolve(strict); // unknown/unresolvable node fails here
    if (resolved == null || resolved.isEmpty() || !resolved.get(0).getName().equals(strict)) {
      throw new IllegalArgumentException("strict-locality node not resolvable: " + strict);
    }
  }
}

Try / catch

try {
  jobClient.submitJob(jobConf);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Invalid resource name:")) {
    jobConf.unset("mapreduce.job.am.strict-locality"); // locality was optional
    jobClient.submitJob(jobConf);
  } else { throw e; }
}

Prevention

When it happens

Trigger: Setting mapreduce.job.am.strict-locality to a value that is not '/'-prefixed and not a node RackResolver can resolve (typo'd hostname, decommissioned/unknown node, an arbitrary string), then submitting the job through YARNRunner.

Common situations: Hardcoded node names after cluster hardware changes; rack names written without the leading '/'; copying a YARN node label or queue name into the strict-locality key by mistake; DNS or /etc/hosts differences between the client and the cluster's topology scripts.

Related errors


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