From dce4a7c765ccb4d73781709d5a540464bfa5aa65 Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Tue, 24 Jul 2012 19:28:43 +0000 Subject: [PATCH] merge -r 1365239:1365240 from trunk. FIXES: MAPREDUCE-4467 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1365241 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 ++ .../org/apache/hadoop/mapred/IndexCache.java | 28 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 7057cdb57b7..59e8a4151ff 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -625,6 +625,9 @@ Release 0.23.3 - UNRELEASED maximum-am-resource-percent configurable on a per queue basis (tgraves via bobby) + MAPREDUCE-4467. IndexCache failures due to missing synchronization + (Kihwal Lee via tgraves) + Release 0.23.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IndexCache.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IndexCache.java index 2dbdf119602..54add3a81ac 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IndexCache.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/IndexCache.java @@ -67,13 +67,13 @@ class IndexCache { if (info == null) { info = readIndexFileToCache(fileName, mapId, expectedIndexOwner); } else { - while (isUnderConstruction(info)) { - try { - // In case the entry is ready after the above check but - // before the following wait, we do timed wait. - info.wait(200); - } catch (InterruptedException e) { - throw new IOException("Interrupted waiting for construction", e); + synchronized(info) { + while (isUnderConstruction(info)) { + try { + info.wait(); + } catch (InterruptedException e) { + throw new IOException("Interrupted waiting for construction", e); + } } } LOG.debug("IndexCache HIT: MapId " + mapId + " found"); @@ -101,13 +101,13 @@ class IndexCache { IndexInformation info; IndexInformation newInd = new IndexInformation(); if ((info = cache.putIfAbsent(mapId, newInd)) != null) { - while (isUnderConstruction(info)) { - try { - // In case the entry is ready after the above check but - // before the following wait, we do timed wait. - info.wait(200); - } catch (InterruptedException e) { - throw new IOException("Interrupted waiting for construction", e); + synchronized(info) { + while (isUnderConstruction(info)) { + try { + info.wait(); + } catch (InterruptedException e) { + throw new IOException("Interrupted waiting for construction", e); + } } } LOG.debug("IndexCache HIT: MapId " + mapId + " found");