You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Xi Fang (JIRA)" <ji...@apache.org> on 2013/06/07 23:56:20 UTC
[jira] [Created] (HADOOP-9633) An incorrect data node might be
added to the network topology, an exception is thrown though
Xi Fang created HADOOP-9633:
-------------------------------
Summary: An incorrect data node might be added to the network topology, an exception is thrown though
Key: HADOOP-9633
URL: https://issues.apache.org/jira/browse/HADOOP-9633
Project: Hadoop Common
Issue Type: Bug
Affects Versions: 1.3.0
Reporter: Xi Fang
Priority: Minor
In NetworkTopology#add(Node node), an incorrect node may be added to the cluster even if an exception is thrown.
This is the original code:
{code}
if (clusterMap.add(node)) {
LOG.info("Adding a new node: "+NodeBase.getPath(node));
if (rack == null) {
numOfRacks++;
}
if (!(node instanceof InnerNode)) {
if (depthOfAllLeaves == -1) {
depthOfAllLeaves = node.getLevel();
} else {
if (depthOfAllLeaves != node.getLevel()) {
LOG.error("Error: can't add leaf node at depth " +
node.getLevel() + " to topology:\n" + oldTopoStr);
throw new InvalidTopologyException("Invalid network topology. " +
"You cannot have a rack and a non-rack node at the same " +
"level of the network topology.");
}
}
}
{code}
This is a potential bug, because a wrong leaf node is already added to the cluster before throwing the exception. However, we can't check this (depthOfAllLeaves != node.getLevel()) before if (clusterMap.add(node)), because node.getLevel() will work correctly only after clusterMap.add(node) has been executed.
A possible solution to this is checking the depthOfAllLeaves in clusterMap.add(node). Note that this is a recursive call. A check should be put at the bottom of this recursive call. If check fails, don't add this leaf and all its upstream racks.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira