CapMoon opened a new pull request, #8462:
URL: https://github.com/apache/hadoop/pull/8462
HDFS-17913. Dead DataNode in Host2NodesMap can break block location sorting
<!--
Thanks for sending a pull request!
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
2. Make sure your PR title starts with JIRA issue id, e.g.,
'HADOOP-17799. Your PR title ...'.
-->
### Description of PR
When HeartbeatManager#heartbeatCheck removes a dead DataNode via
DatanodeManager#removeDeadDatanode, the node is removed from NetworkTopology,
but it may still be returned by host2DatanodeMap.
If an HDFS client is co-located on the same host/IP as that dead DataNode,
DatanodeManager#sortLocatedBlock may treat the client as a DataNode reader.
Since the descriptor has already been removed from NetworkTopology, its parent
is null, and NetworkTopology#sortByDistance can compute incorrect weights for
replicas. This may cause rack locality to be lost, especially when
dfs.namenode.read.considerLoad=true.
Expected behavior:
A DataNode descriptor detached from NetworkTopology should not be treated as
a DataNode reader.
Proposed fix:
In DatanodeManager#sortLocatedBlock, ignore a host-map hit whose topology
parent is null
### How was this patch tested?
Tested in unit test
### For code changes:
- [ ] Does the title or this PR starts with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: have the integration tests been executed and the
endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
### AI Tooling
If an AI tool was used:
- [ ] The PR includes the phrase "Contains content generated by <tool>"
where <tool> is the name of the AI tool used.
- [ ] My use of AI contributions follows the ASF legal policy
https://www.apache.org/legal/generative-tooling.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]