{"record":{"id":"a9aed02c9adca926","repo":"apache/hadoop","slug":"job-status-not-available","errorCode":null,"errorMessage":"Job status not available ","messagePattern":"Job status not available ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java","lineNumber":340,"sourceCode":"    \n  /** Some methods need to update status immediately. So, refresh\n   * immediately\n   * @throws IOException\n   */\n  synchronized void updateStatus() throws IOException {\n    try {\n      this.status = ugi.doAs(new PrivilegedExceptionAction<JobStatus>() {\n        @Override\n        public JobStatus run() throws IOException, InterruptedException {\n          return cluster.getClient().getJobStatus(getJobID());\n        }\n      });\n    }\n    catch (InterruptedException ie) {\n      throw new IOException(ie);\n    }\n    if (this.status == null) {\n      throw new IOException(\"Job status not available \");\n    }\n    this.statustime = System.currentTimeMillis();\n  }\n  \n  public JobStatus getStatus() throws IOException, InterruptedException {\n    ensureState(JobState.RUNNING);\n    updateStatus();\n    return status;\n  }\n\n  /**\n   * Returns the current state of the Job.\n   * \n   * @return JobStatus#State\n   * @throws IOException\n   * @throws InterruptedException\n   */\n  public JobStatus.State getJobState() ","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Job.java#L322-L358","documentation":"Job.updateStatus() asks the attached Cluster's client (ResourceManager's MR client protocol, or a JobTracker) for the JobStatus of this job id. If the remote service returns null — it no longer knows the job — the method throws IOException('Job status not available ') (note the trailing space, useful for message matching). It surfaces through getStatus(), monitorAndPrintJob(), and getState().","triggerScenarios":"Calling job.getStatus() after the job finished and was retired from the RM's in-memory job table; using a Job id that belongs to a different or restarted cluster (RM restart loses job state); querying in the first instants after submit() before the MR ApplicationMaster registers the job.","commonSituations":"Long-lived monitoring threads or dashboards holding a Job object for days; RM failover/restart during a poll; pointing the client at the JobHistoryServer address where the active ResourceManager is expected; job ids carried across environments (dev vs prod configs).","solutions":["For finished jobs, query the job history layer instead of polling the live cluster (JobHistory API, jhist files, or the MR JobHistory UI)","Stop polling once job.isComplete() returns true — retired jobs will never come back from the RM","Confirm the client targets the cluster the job ran on (yarn.resourcemanager.address / mapreduce.jobtracker.address)","Right after submit(), tolerate the error once or twice with a short backoff — registration can lag"],"exampleFix":"// before\nwhile (true) {\n  JobStatus s = job.getStatus(); // throws 'Job status not available ' once the job is retired\n  Thread.sleep(1000);\n}\n\n// after\nwhile (!job.isComplete()) {\n  JobStatus s = job.getStatus();\n  Thread.sleep(1000);\n}\n// after completion use the history server for final details","handlingStrategy":"try-catch","validationCode":"// avoid polling a retired job: stop at completion\nwhile (!job.isComplete()) {\n  JobStatus s = job.getStatus(); // safe while the RM still tracks the job\n  logProgress(s);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return job.getStatus();\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Job status not available\")) {\n    // job retired from the live cluster: fall back to the job history server\n    return fetchStatusFromHistoryServer(job.getJobID());\n  }\n  throw e; // real connectivity problem — do not mask it\n}","preventionTips":["Poll only until isComplete() is true, then switch to history-based reporting","Pin the client to the exact cluster (RM addresses) the job ran on","After submit(), tolerate one transient failure with a short backoff before giving up"],"tags":["job-status","cluster-rpc","retired-job","yarn","mapreduce"],"backgroundTag":"job-status-unavailable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}