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
This commit is contained in:
Thomas Graves 2012-07-24 19:28:43 +00:00
parent 99f87b520e
commit dce4a7c765
2 changed files with 17 additions and 14 deletions

View File

@ -625,6 +625,9 @@ Release 0.23.3 - UNRELEASED
maximum-am-resource-percent configurable on a per queue basis (tgraves via maximum-am-resource-percent configurable on a per queue basis (tgraves via
bobby) bobby)
MAPREDUCE-4467. IndexCache failures due to missing synchronization
(Kihwal Lee via tgraves)
Release 0.23.2 - UNRELEASED Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -67,13 +67,13 @@ class IndexCache {
if (info == null) { if (info == null) {
info = readIndexFileToCache(fileName, mapId, expectedIndexOwner); info = readIndexFileToCache(fileName, mapId, expectedIndexOwner);
} else { } else {
while (isUnderConstruction(info)) { synchronized(info) {
try { while (isUnderConstruction(info)) {
// In case the entry is ready after the above check but try {
// before the following wait, we do timed wait. info.wait();
info.wait(200); } catch (InterruptedException e) {
} catch (InterruptedException e) { throw new IOException("Interrupted waiting for construction", e);
throw new IOException("Interrupted waiting for construction", e); }
} }
} }
LOG.debug("IndexCache HIT: MapId " + mapId + " found"); LOG.debug("IndexCache HIT: MapId " + mapId + " found");
@ -101,13 +101,13 @@ class IndexCache {
IndexInformation info; IndexInformation info;
IndexInformation newInd = new IndexInformation(); IndexInformation newInd = new IndexInformation();
if ((info = cache.putIfAbsent(mapId, newInd)) != null) { if ((info = cache.putIfAbsent(mapId, newInd)) != null) {
while (isUnderConstruction(info)) { synchronized(info) {
try { while (isUnderConstruction(info)) {
// In case the entry is ready after the above check but try {
// before the following wait, we do timed wait. info.wait();
info.wait(200); } catch (InterruptedException e) {
} catch (InterruptedException e) { throw new IOException("Interrupted waiting for construction", e);
throw new IOException("Interrupted waiting for construction", e); }
} }
} }
LOG.debug("IndexCache HIT: MapId " + mapId + " found"); LOG.debug("IndexCache HIT: MapId " + mapId + " found");