MAPREDUCE-4467. IndexCache failures due to missing synchronization (Kihwal Lee via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1365240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Graves 2012-07-24 19:27:29 +00:00
parent a2d5603106
commit cdef12644b
2 changed files with 17 additions and 14 deletions

View File

@ -749,6 +749,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

View File

@ -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");