HDFS-5132. Deadlock in NameNode between SafeModeMonitor#run and DatanodeManager#handleHeartbeat. Contributed by Kihwal Lee.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1517989 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Kihwal Lee 2013-08-27 21:04:24 +00:00
parent 10a62366a5
commit 1bfcab9689
2 changed files with 18 additions and 4 deletions

View File

@ -395,6 +395,9 @@ Release 2.1.1-beta - UNRELEASED
HDFS-5124. DelegationTokenSecretManager#retrievePassword can cause deadlock HDFS-5124. DelegationTokenSecretManager#retrievePassword can cause deadlock
in NameNode. (Daryn Sharp via jing9) in NameNode. (Daryn Sharp via jing9)
HDFS-5132. Deadlock in NameNode between SafeModeMonitor#run and
DatanodeManager#handleHeartbeat. (kihwal)
Release 2.1.0-beta - 2013-08-22 Release 2.1.0-beta - 2013-08-22
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -4798,7 +4798,21 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
*/ */
@Override @Override
public void run() { public void run() {
while (fsRunning && (safeMode != null && !safeMode.canLeave())) { while (fsRunning) {
writeLock();
try {
if (safeMode == null) { // Not in safe mode.
break;
}
if (safeMode.canLeave()) {
// Leave safe mode.
safeMode.leave();
break;
}
} finally {
writeUnlock();
}
try { try {
Thread.sleep(recheckInterval); Thread.sleep(recheckInterval);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@ -4807,9 +4821,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
} }
if (!fsRunning) { if (!fsRunning) {
LOG.info("NameNode is being shutdown, exit SafeModeMonitor thread"); LOG.info("NameNode is being shutdown, exit SafeModeMonitor thread");
} else {
// leave safe mode and stop the monitor
leaveSafeMode();
} }
smmthread = null; smmthread = null;
} }