From 5ffb26c2a9e03fb57057462897dff7dc65887034 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Mon, 14 Nov 2016 20:20:50 +0000 Subject: [PATCH] MAPREDUCE-6797. Job history server scans can become blocked on a single, slow entry. Contributed by Prabhu Joseph (cherry picked from commit 99c2bbd337942e4bc7b246a88dff53f98e530651) --- .../mapreduce/v2/hs/HistoryFileManager.java | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryFileManager.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryFileManager.java index 69faba9a784..0789c35d016 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryFileManager.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryFileManager.java @@ -231,38 +231,36 @@ public class HistoryFileManager extends AbstractService { JobId firstMoveFailedKey = null; int moveFailedCount = 0; - while(cache.size() > maxSize && keys.hasNext()) { + while (cache.size() > maxSize && keys.hasNext()) { JobId key = keys.next(); HistoryFileInfo firstValue = cache.get(key); - if(firstValue != null) { - synchronized(firstValue) { - if (firstValue.isMovePending()) { - if(firstValue.didMoveFail() && - firstValue.jobIndexInfo.getFinishTime() <= cutoff) { - cache.remove(key); - //Now lets try to delete it - try { - firstValue.delete(); - } catch (IOException e) { - LOG.error("Error while trying to delete history files" + - " that could not be moved to done.", e); - } - } else { - if (firstValue.didMoveFail()) { - if (moveFailedCount == 0) { - firstMoveFailedKey = key; - } - moveFailedCount += 1; - } else { - if (inIntermediateCount == 0) { - firstInIntermediateKey = key; - } - inIntermediateCount += 1; - } + if (firstValue != null) { + if (firstValue.isMovePending()) { + if (firstValue.didMoveFail() && + firstValue.jobIndexInfo.getFinishTime() <= cutoff) { + cache.remove(key); + // Now lets try to delete it + try { + firstValue.delete(); + } catch (IOException e) { + LOG.error("Error while trying to delete history files" + + " that could not be moved to done.", e); } } else { - cache.remove(key); + if (firstValue.didMoveFail()) { + if (moveFailedCount == 0) { + firstMoveFailedKey = key; + } + moveFailedCount += 1; + } else { + if (inIntermediateCount == 0) { + firstInIntermediateKey = key; + } + inIntermediateCount += 1; + } } + } else { + cache.remove(key); } } }