[
https://issues.apache.org/jira/browse/HDFS-14527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16855903#comment-16855903
]
Ayush Saxena commented on HDFS-14527:
-------------------------------------
Thanx [~hexiaoqiao] for the patch, though the scenario seems quite difficult to
happen at production, but still technically it can.
* Well if we pull {{numRacks}} calculation above the {{clusterSize}}
calculation, same logic shall work? The present approach is correct too. Just
if we want to keep the same logic.
{code:java}
try {
chooseTargetFuturn.get();
} catch (ArithmeticException ae) {
fail("It meets RuntimeException since there are no DataNodes!");
}
{code}
* This isn't working, This throws {{java.util.concurrent.ExecutionException}}
the cause for which is {{ArithmeticException}} . May be you can let the
exception surface in case of failure, rather than having this. Would be better
for someone landing up with this failed.
* For the Test do you need 6 Dn's? can go away with 2 too, I guess, might save
some time.
* For the miniDfsCluster, instead having finally to close at end you may use
try with resources. Somewhat like this.
{code:java}
try(MiniDFSCluster miniCluster = new
MiniDFSCluster.Builder(conf).racks(racks)
.hosts(hosts).numDataNodes(hosts.length).build()){
{code}
* Can make the name better little generic as compared to existing
{{TestRedundancyMonitorChooseTarget}} may be related to BPP, and put a javadoc
on the test explaining the scenario, So, that the test class may be used by
someone else too in future.
> Stop all DataNodes may result in NN terminate
> ---------------------------------------------
>
> Key: HDFS-14527
> URL: https://issues.apache.org/jira/browse/HDFS-14527
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: namenode
> Reporter: He Xiaoqiao
> Assignee: He Xiaoqiao
> Priority: Major
> Attachments: HDFS-14527.001.patch, HDFS-14527.002.patch,
> HDFS-14527.003.patch
>
>
> If we stop all datanodes of cluster, BlockPlacementPolicyDefault#chooseTarget
> may get ArithmeticException when calling #getMaxNodesPerRack, which throws
> the runtime exception out to BlockManager's ReplicationMonitor thread and
> then terminate the NN.
> The root cause is that BlockPlacementPolicyDefault#chooseTarget not hold the
> global lock, and if all DataNodes are dead between
> {{clusterMap.getNumberOfLeaves()}} and {{getMaxNodesPerRack}} then it meet
> {{ArithmeticException}} while invoke {{getMaxNodesPerRack}}.
> {code:java}
> private DatanodeStorageInfo[] chooseTarget(int numOfReplicas,
> Node writer,
> List<DatanodeStorageInfo> chosenStorage,
> boolean returnChosenNodes,
> Set<Node> excludedNodes,
> long blocksize,
> final BlockStoragePolicy storagePolicy,
> EnumSet<AddBlockFlag> addBlockFlags,
> EnumMap<StorageType, Integer> sTypes) {
> if (numOfReplicas == 0 || clusterMap.getNumOfLeaves()==0) {
> return DatanodeStorageInfo.EMPTY_ARRAY;
> }
> ......
> int[] result = getMaxNodesPerRack(chosenStorage.size(), numOfReplicas);
> ......
> }
> {code}
> Some detailed log show as following.
> {code:java}
> 2019-05-31 12:29:21,803 ERROR
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager:
> ReplicationMonitor thread received Runtime exception.
> java.lang.ArithmeticException: / by zero
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault.getMaxNodesPerRack(BlockPlacementPolicyDefault.java:282)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault.chooseTarget(BlockPlacementPolicyDefault.java:228)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyDefault.chooseTarget(BlockPlacementPolicyDefault.java:132)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager$ReplicationWork.chooseTargets(BlockManager.java:4533)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager$ReplicationWork.access$1800(BlockManager.java:4493)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeReplicationWorkForBlocks(BlockManager.java:1954)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeReplicationWork(BlockManager.java:1830)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.computeDatanodeWork(BlockManager.java:4453)
> at
> org.apache.hadoop.hdfs.server.blockmanagement.BlockManager$ReplicationMonitor.run(BlockManager.java:4388)
> at java.lang.Thread.run(Thread.java:745)
> 2019-05-31 12:29:21,805 INFO org.apache.hadoop.util.ExitUtil: Exiting with
> status 1
> {code}
> To be honest, this is not serious bug and not reprod easily, since if we stop
> all Datanodes and only keep NameNode lives, HDFS could be not offer service
> normally and we could only retrieve directory. It may be one corner case.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]