HDFS-4937. ReplicationMonitor can infinite-loop in BlockPlacementPolicyDefault#chooseRandom(). Contributed by Kihwal Lee.
(cherry picked from commit 43539b5ff4
)
This commit is contained in:
parent
1c80473a41
commit
0c7fd26302
|
@ -1364,6 +1364,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-9332. Fix Precondition failures from NameNodeEditLogRoller while
|
HDFS-9332. Fix Precondition failures from NameNodeEditLogRoller while
|
||||||
saving namespace. (wang)
|
saving namespace. (wang)
|
||||||
|
|
||||||
|
HDFS-4937. ReplicationMonitor can infinite-loop in
|
||||||
|
BlockPlacementPolicyDefault#chooseRandom() (kihwal)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -659,6 +659,7 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy {
|
||||||
|
|
||||||
int numOfAvailableNodes = clusterMap.countNumOfAvailableNodes(
|
int numOfAvailableNodes = clusterMap.countNumOfAvailableNodes(
|
||||||
scope, excludedNodes);
|
scope, excludedNodes);
|
||||||
|
int refreshCounter = numOfAvailableNodes;
|
||||||
StringBuilder builder = null;
|
StringBuilder builder = null;
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
builder = debugLoggingBuilder.get();
|
builder = debugLoggingBuilder.get();
|
||||||
|
@ -708,6 +709,17 @@ public class BlockPlacementPolicyDefault extends BlockPlacementPolicy {
|
||||||
// If no candidate storage was found on this DN then set badTarget.
|
// If no candidate storage was found on this DN then set badTarget.
|
||||||
badTarget = (storage == null);
|
badTarget = (storage == null);
|
||||||
}
|
}
|
||||||
|
// 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) {
|
||||||
|
refreshCounter = clusterMap.countNumOfAvailableNodes(scope,
|
||||||
|
excludedNodes);
|
||||||
|
// It has already gone through enough number of nodes.
|
||||||
|
if (refreshCounter <= excludedNodes.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfReplicas>0) {
|
if (numOfReplicas>0) {
|
||||||
|
|
Loading…
Reference in New Issue