{"record":{"id":"448ad9fbc72bd804","repo":"apache/hadoop","slug":"only-one-of-the-following-keys-can-be-specified-fo-448ad9","errorCode":null,"errorMessage":"Only one of the following keys can be specified for a single job: memory-mb, memory","messagePattern":"Only one of the following keys can be specified for a single job: memory-mb, memory","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java","lineNumber":687,"sourceCode":"      appContext.setPriority(Priority.newInstance(iPriority));\n    }\n\n    return appContext;\n  }\n\n  private List<ResourceRequest> generateResourceRequests() throws IOException {\n    Resource capability = recordFactory.newRecordInstance(Resource.class);\n    boolean memorySet = false;\n    boolean cpuVcoresSet = false;\n    List<ResourceInformation> resourceRequests = ResourceUtils\n        .getRequestedResourcesFromConfig(conf, MR_AM_RESOURCE_PREFIX);\n    for (ResourceInformation resourceReq : resourceRequests) {\n      String resourceName = resourceReq.getName();\n      if (MRJobConfig.RESOURCE_TYPE_NAME_MEMORY.equals(resourceName) ||\n          MRJobConfig.RESOURCE_TYPE_ALTERNATIVE_NAME_MEMORY.equals(\n              resourceName)) {\n        if (memorySet) {\n          throw new IllegalArgumentException(\n              \"Only one of the following keys \" +\n                  \"can be specified for a single job: \" +\n                  MRJobConfig.RESOURCE_TYPE_ALTERNATIVE_NAME_MEMORY + \", \" +\n                  MRJobConfig.RESOURCE_TYPE_NAME_MEMORY);\n        }\n        String units = isEmpty(resourceReq.getUnits()) ?\n            ResourceUtils.getDefaultUnit(ResourceInformation.MEMORY_URI) :\n              resourceReq.getUnits();\n        capability.setMemorySize(\n            UnitsConversionUtil.convert(units, \"Mi\", resourceReq.getValue()));\n        memorySet = true;\n        if (conf.get(MRJobConfig.MR_AM_VMEM_MB) != null) {\n          LOG.warn(\"Configuration \" + MR_AM_RESOURCE_PREFIX +\n              resourceName + \"=\" + resourceReq.getValue() +\n              resourceReq.getUnits() + \" is overriding the \" +\n              MRJobConfig.MR_AM_VMEM_MB + \"=\" +\n              conf.get(MRJobConfig.MR_AM_VMEM_MB) + \" configuration\");\n        }","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java#L669-L705","documentation":"While building the MR ApplicationMaster's resource requests, YARNRunner.generateResourceRequests calls ResourceUtils.getRequestedResourcesFromConfig over the yarn.app.mapreduce.am.resource.* prefix. 'memory-mb' and 'memory' are two config spellings for the same memory resource; the loop tracks a memorySet flag and throws IllegalArgumentException as soon as the second alias appears, because the two keys would compete for the same Resource field.","triggerScenarios":"mapred-site.xml (or a -D override) contains both yarn.app.mapreduce.am.resource.memory-mb and yarn.app.mapreduce.am.resource.memory, and a job is submitted through YARNRunner. The exception is thrown during submitJob, before any container is requested.","commonSituations":"Merging job configs from multiple templates where one uses the legacy 'memory-mb' spelling and newer code sets 'memory'; site files upgraded across Hadoop versions accumulating both keys; automation that sets memory programmatically on top of a site file that already defines the alias.","solutions":["Remove one of the two keys from mapred-site.xml / job Configuration; keep the canonical 'yarn.app.mapreduce.am.resource.memory' form","If a -D CLI override introduced the duplicate, drop the site-file copy instead","Dump the effective config (e.g. 'hadoop job -conf ...' or conf.get on both keys in a dry run) to find where each alias enters the configuration chain"],"exampleFix":"# before (mapred-site.xml carries both)\n<property><name>yarn.app.mapreduce.am.resource.memory-mb</name><value>2048</value></property>\n<property><name>yarn.app.mapreduce.am.resource.memory</name><value>2048</value></property>\n\n# after (single canonical key)\n<property><name>yarn.app.mapreduce.am.resource.memory</name><value>2048</value></property>","handlingStrategy":"validation","validationCode":"if (conf.get(\"yarn.app.mapreduce.am.resource.memory-mb\") != null\n    && conf.get(\"yarn.app.mapreduce.am.resource.memory\") != null) {\n  throw new IllegalArgumentException(\n      \"Both memory-mb and memory set for the AM; remove one (keep 'memory')\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  jobClient.submitJob(jobConf);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"memory-mb\")) {\n    jobConf.unset(\"yarn.app.mapreduce.am.resource.memory-mb\"); // keep canonical key\n    jobClient.submitJob(jobConf);\n  } else { throw e; }\n}","preventionTips":["Standardize on the canonical 'yarn.app.mapreduce.am.resource.<type>' spelling in all templates","Audit merged configurations (site files + -D overrides) for duplicate resource aliases before submission","In CI, assert that at most one memory alias is present in generated job configs"],"tags":["configuration","resources","yarn","mapreduce","appmaster"],"backgroundTag":"conflicting-configuration-keys","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}