diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0a68720d607..48ebda3437d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -395,6 +395,9 @@ Release 2.1.1-beta - UNRELEASED HDFS-5124. DelegationTokenSecretManager#retrievePassword can cause deadlock 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 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 569f2165c7a..178f3d9b087 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -4798,7 +4798,21 @@ public class FSNamesystem implements Namesystem, FSClusterStats, */ @Override 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 { Thread.sleep(recheckInterval); } catch (InterruptedException ie) { @@ -4807,9 +4821,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats, } if (!fsRunning) { LOG.info("NameNode is being shutdown, exit SafeModeMonitor thread"); - } else { - // leave safe mode and stop the monitor - leaveSafeMode(); } smmthread = null; }