MAPREDUCE-6762, we found this issue in a cluster where Pig query occasionally failed on NPE - "Pig uses JobControl API to track MR job status, but sometimes Job History Server failed to flush job meta files to HDFS which caused the status update failed." Beside NPE in o.a.h.mapreduce.Job.getJobName, we also get NPE in Job.updateStatus() and the exception is as following:
We found state here is null. However, we already check the job state to be RUNNING as code below:
The only possible reason here is two threads are calling here for the same time: ensure state first, then one thread update the state to null while the other thread hit NPE issue here.
We should fix this NPE exception.