{"record":{"id":"ad160d90fee7a868","repo":"apache/hadoop","slug":"killing-tasks-in-localjobrunner-is-not-supported","errorCode":null,"errorMessage":"Killing tasks in LocalJobRunner is not supported","messagePattern":"Killing tasks in LocalJobRunner is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","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":814,"sourceCode":"    return job.status;\n\n  }\n\n  public void killJob(org.apache.hadoop.mapreduce.JobID id) {\n    jobs.get(JobID.downgrade(id)).killed = true;\n    jobs.get(JobID.downgrade(id)).interrupt();\n  }\n\n  public void setJobPriority(org.apache.hadoop.mapreduce.JobID id,\n      String jp) throws IOException {\n    throw new UnsupportedOperationException(\"Changing job priority \" +\n                      \"in LocalJobRunner is not supported.\");\n  }\n  \n  /** Throws {@link UnsupportedOperationException} */\n  public boolean killTask(org.apache.hadoop.mapreduce.TaskAttemptID taskId,\n      boolean shouldFail) throws IOException {\n    throw new UnsupportedOperationException(\"Killing tasks in \" +\n    \"LocalJobRunner is not supported\");\n  }\n\n  public org.apache.hadoop.mapreduce.TaskReport[] getTaskReports(\n      org.apache.hadoop.mapreduce.JobID id, TaskType type) {\n    return new org.apache.hadoop.mapreduce.TaskReport[0];\n  }\n\n  public org.apache.hadoop.mapreduce.JobStatus getJobStatus(\n      org.apache.hadoop.mapreduce.JobID id) {\n    Job job = jobs.get(JobID.downgrade(id));\n    if(job != null)\n      return job.status;\n    else \n      return null;\n  }\n  \n  public org.apache.hadoop.mapreduce.Counters getJobCounters(","sourceCodeStart":796,"sourceCodeEnd":832,"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#L796-L832","documentation":"LocalJobRunner.killTask(TaskAttemptID, boolean) unconditionally throws UnsupportedOperationException: the local runner executes all tasks on threads of one Job thread, so individual task attempts cannot be killed or failed independently. Job-level kill is supported — killJob() sets the Job.killed flag and interrupts the worker thread.","triggerScenarios":"Calling JobClient.killTask(attemptId, shouldFail), killTaskAttempt, or 'hadoop job -kill-task' / '-fail-task' against a job whose framework is local.","commonSituations":"Test harnesses that mimic cluster administration (kill a mapper to test retry logic) but run under LocalJobRunner; porting cluster-operations tooling to a local dev setup; retry-behavior tests that must instead run on MiniYARNCluster.","solutions":["Kill the whole job instead (JobClient.killJob) when running locally","Run the test on a real or mini YARN cluster (MiniYARNCluster / mapreduce.framework.name=yarn) when per-task kill semantics are required","Guard the call behind a framework-name check before invoking"],"exampleFix":"// before\nclient.killTask(attemptId, false); // throws in local mode\n\n// after\nif (\"local\".equals(conf.get(\"mapreduce.framework.name\", \"local\"))) {\n  client.killJob(jobId); // only job-level kill exists locally\n} else {\n  client.killTask(attemptId, false);\n}","handlingStrategy":"validation","validationCode":"if (!\"local\".equals(conf.get(\"mapreduce.framework.name\", \"local\"))) {\n  client.killTask(attemptId, false);\n} else {\n  client.killJob(jobId); // local runner: job-level kill only\n}","typeGuard":null,"tryCatchPattern":"try {\n  client.killTask(attemptId, shouldFail);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Per-task kill unsupported locally; killing job instead\");\n  client.killJob(jobId);\n}","preventionTips":["Run retry/kill-semantics tests on MiniYARNCluster, not LocalJobRunner","Centralize framework-mode checks in one helper used by all job-control code"],"tags":["hadoop","mapreduce","local-mode","task-kill","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}