YARN-2594. Potential deadlock in RM when querying ApplicationResourceUsageReport. (Wangda Tan via kasha)

(cherry picked from commit 14d60dadc2)
This commit is contained in:
Karthik Kambatla 2014-09-30 16:12:27 -07:00
parent a0305ba3fc
commit 5a43b795b7
2 changed files with 18 additions and 35 deletions

View File

@ -458,6 +458,9 @@ Release 2.6.0 - UNRELEASED
YARN-2387. Resource Manager crashes with NPE due to lack of YARN-2387. Resource Manager crashes with NPE due to lack of
synchronization (Mit Desai via jlowe) synchronization (Mit Desai via jlowe)
YARN-2594. Potential deadlock in RM when querying
ApplicationResourceUsageReport. (Wangda Tan via kasha)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -128,7 +128,8 @@ public class RMAppImpl implements RMApp, Recoverable {
private long startTime; private long startTime;
private long finishTime = 0; private long finishTime = 0;
private long storedFinishTime = 0; private long storedFinishTime = 0;
private RMAppAttempt currentAttempt; // This field isn't protected by readlock now.
private volatile RMAppAttempt currentAttempt;
private String queue; private String queue;
private EventHandler handler; private EventHandler handler;
private static final AppFinishedTransition FINISHED_TRANSITION = private static final AppFinishedTransition FINISHED_TRANSITION =
@ -438,16 +439,11 @@ public class RMAppImpl implements RMApp, Recoverable {
@Override @Override
public float getProgress() { public float getProgress() {
this.readLock.lock(); RMAppAttempt attempt = this.currentAttempt;
if (attempt != null) {
try { return attempt.getProgress();
if (this.currentAttempt != null) {
return this.currentAttempt.getProgress();
} }
return 0; return 0;
} finally {
this.readLock.unlock();
}
} }
@Override @Override
@ -478,13 +474,7 @@ public class RMAppImpl implements RMApp, Recoverable {
@Override @Override
public RMAppAttempt getCurrentAppAttempt() { public RMAppAttempt getCurrentAppAttempt() {
this.readLock.lock();
try {
return this.currentAttempt; return this.currentAttempt;
} finally {
this.readLock.unlock();
}
} }
@Override @Override
@ -655,30 +645,20 @@ public class RMAppImpl implements RMApp, Recoverable {
@Override @Override
public String getTrackingUrl() { public String getTrackingUrl() {
this.readLock.lock(); RMAppAttempt attempt = this.currentAttempt;
if (attempt != null) {
try { return attempt.getTrackingUrl();
if (this.currentAttempt != null) {
return this.currentAttempt.getTrackingUrl();
} }
return null; return null;
} finally {
this.readLock.unlock();
}
} }
@Override @Override
public String getOriginalTrackingUrl() { public String getOriginalTrackingUrl() {
this.readLock.lock(); RMAppAttempt attempt = this.currentAttempt;
if (attempt != null) {
try { return attempt.getOriginalTrackingUrl();
if (this.currentAttempt != null) {
return this.currentAttempt.getOriginalTrackingUrl();
} }
return null; return null;
} finally {
this.readLock.unlock();
}
} }
@Override @Override