HDFS-4937. ReplicationMonitor can infinite-loop in BlockPlacementPolicyDefault#chooseRandom(). Contributed by Kihwal Lee.
(cherry picked from commit ff47f35deed14ba6463cba76f0e6a6c15abb3eca)
This commit is contained in:
parent
397b554c36
commit
616ed9084b
@ -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
|
||||
|
@ -622,6 +622,7 @@ protected DatanodeStorageInfo chooseRandom(int numOfReplicas,
|
||||
|
||||
int numOfAvailableNodes = clusterMap.countNumOfAvailableNodes(
|
||||
scope, excludedNodes);
|
||||
int refreshCounter = numOfAvailableNodes;
|
||||
StringBuilder builder = null;
|
||||
if (LOG.isDebugEnabled()) {
|
||||
builder = debugLoggingBuilder.get();
|
||||
@ -675,6 +676,14 @@ protected DatanodeStorageInfo chooseRandom(int numOfReplicas,
|
||||
// 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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user