Repository: hadoop Updated Branches: refs/heads/branch-2.7 397b554c3 -> 616ed9084
HDFS-4937. ReplicationMonitor can infinite-loop in BlockPlacementPolicyDefault#chooseRandom(). Contributed by Kihwal Lee. (cherry picked from commit ff47f35deed14ba6463cba76f0e6a6c15abb3eca) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/616ed908 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/616ed908 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/616ed908 Branch: refs/heads/branch-2.7 Commit: 616ed9084be4dc337c2ececa7aecc4ab7899a75a Parents: 397b554 Author: Kihwal Lee <[email protected]> Authored: Thu Nov 5 09:27:36 2015 -0600 Committer: Kihwal Lee <[email protected]> Committed: Thu Nov 5 09:27:36 2015 -0600 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../server/blockmanagement/BlockPlacementPolicyDefault.java | 9 +++++++++ 2 files changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/616ed908/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 45ce310..3e62c5d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -15,6 +15,9 @@ Release 2.7.3 - UNRELEASED HDFS-9289. Make DataStreamer#block thread safe and verify genStamp in commitBlock. (Chang Li via kihwal) + HDFS-4937. ReplicationMonitor can infinite-loop in + BlockPlacementPolicyDefault#chooseRandom(). (kihwal) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/616ed908/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java index 97ea782..93056e9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyDefault.java @@ -622,6 +622,7 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy { int numOfAvailableNodes = clusterMap.countNumOfAvailableNodes( scope, excludedNodes); + int refreshCounter = numOfAvailableNodes; StringBuilder builder = null; if (LOG.isDebugEnabled()) { builder = debugLoggingBuilder.get(); @@ -675,6 +676,14 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy { // If no candidate storage was found on this DN then set badTarget. badTarget = (i == storages.length); } + // Refresh the node count. If the live node count became smaller, + // but it is not reflected in this loop, it may loop forever in case + // the replicas/rack cannot be satisfied. + if (--refreshCounter == 0) { + numOfAvailableNodes = clusterMap.countNumOfAvailableNodes(scope, + excludedNodes); + refreshCounter = numOfAvailableNodes; + } } if (numOfReplicas>0) {
