{"record":{"id":"5daadce08b4d623f","repo":"apache/hadoop","slug":"configured-mapreduce-local-map-tasks-maximum-must","errorCode":null,"errorMessage":"Configured mapreduce.local.map.tasks.maximum must be >= 1","messagePattern":"Configured mapreduce\\.local\\.map\\.tasks\\.maximum must be >= 1","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalJobRunner.java","lineNumber":417,"sourceCode":"      for (int i = 0; i < numReduces; i++) {\n        this.reduceCounters[i] = new Counters();\n      }\n\n      this.numMapTasks = numMaps;\n      this.numReduceTasks = numReduces;\n    }\n\n    /**\n     * Creates the executor service used to run map tasks.\n     *\n     * @return an ExecutorService instance that handles map tasks\n     */\n    protected synchronized ExecutorService createMapExecutor() {\n\n      // Determine the size of the thread pool to use\n      int maxMapThreads = job.getInt(LOCAL_MAX_MAPS, 1);\n      if (maxMapThreads < 1) {\n        throw new IllegalArgumentException(\n            \"Configured \" + LOCAL_MAX_MAPS + \" must be >= 1\");\n      }\n      maxMapThreads = Math.min(maxMapThreads, this.numMapTasks);\n      maxMapThreads = Math.max(maxMapThreads, 1); // In case of no tasks.\n\n      LOG.debug(\"Starting mapper thread pool executor.\");\n      LOG.debug(\"Max local threads: \" + maxMapThreads);\n      LOG.debug(\"Map tasks to process: \" + this.numMapTasks);\n\n      // Create a new executor service to drain the work queue.\n      ThreadFactory tf = new ThreadFactoryBuilder()\n        .setNameFormat(\"LocalJobRunner Map Task Executor #%d\")\n        .build();\n      ExecutorService executor = HadoopExecutors.newFixedThreadPool(\n          maxMapThreads, tf);\n\n      return executor;\n    }","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalJobRunner.java#L399-L435","documentation":"LocalJobRunner.createMapExecutor sizes its map thread pool from mapreduce.local.map.tasks.maximum (LOCAL_MAX_MAPS, default 1). A configured value below 1 - zero or negative - fails fast with IllegalArgumentException before the local job starts.","triggerScenarios":"Configuration sets mapreduce.local.map.tasks.maximum to 0 or a negative number - via an XML file, -D on the command line, or LocalJobRunner's setMaxMapThreads API (LocalJobRunner.java:966).","commonSituations":"Tuning templates copied from mapreduce.job.maps; environment-specific overrides with a placeholder value of 0; an attempt to serialize local maps; property written into the wrong key by mistake.","solutions":["Set the property to 1 or higher (for example 4), or remove it to fall back to the default 1","If set programmatically, guard setMaxMapThreads with Math.max(1, n)","Inspect the failing job's job.xml to find which source set the bad value"],"exampleFix":"// before\nconf.setInt(\"mapreduce.local.map.tasks.maximum\", 0);\n\n// after\nconf.setInt(\"mapreduce.local.map.tasks.maximum\", 4);","handlingStrategy":"validation","validationCode":"int maxMaps = conf.getInt(\"mapreduce.local.map.tasks.maximum\", 1);\nif (maxMaps < 1) {\n  throw new IllegalArgumentException(\n      \"mapreduce.local.map.tasks.maximum must be >= 1, got \" + maxMaps);\n}\n// safe to run the local job","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate both mapreduce.local.*.tasks.maximum values in a shared config-check before any local run","Do not copy mapreduce.job.maps tuning into the local-runner keys","Clamp programmatic setMaxMapThreads calls with Math.max(1, n)"],"tags":["mapreduce","local-job-runner","configuration","thread-pool"],"backgroundTag":"invalid-configuration-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}