rich7420 commented on code in PR #11688:
URL: https://github.com/apache/ozone/pull/11688#discussion_r4503303593


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeStateManager.java:
##########
@@ -354,20 +354,30 @@ public void updateLastKnownVersionInfo(DatanodeDetails 
datanodeDetails,
   }
 
   /**
-   * Update node.
+   * Update node, in the network topology as well. The new {@link 
DatanodeInfo} itself goes into the topology first,
+   * so it has its parent before it replaces the old one in the node state.
+   * <p>
+   * At the same time, the health check can change the topology for the old 
{@link DatanodeInfo}. It removes the node
+   * when the node becomes DEAD, and adds it back when the node recovers. This 
is rare, so the two do not lock each
+   * other out. Instead, each one checks the topology after its own change, 
and does the update again if the other one
+   * got in between.
    *
    * @param datanodeDetails the datanode details
    * @param versionInfo the datanode version information
    * @throws NodeNotFoundException the node not found exception
    */
-  public void updateNode(DatanodeDetails datanodeDetails,
-                         DatanodeVersionProto versionInfo)
-          throws NodeNotFoundException {
+  public void updateNode(DatanodeDetails datanodeDetails, DatanodeVersionProto 
versionInfo)
+      throws NodeNotFoundException {
     final DatanodeInfo newInfo = newDatanodeInfo(datanodeDetails, versionInfo);
+    clusterMap.update(getNode(datanodeDetails), newInfo);
     final DatanodeInfo oldInfo = nodeStateMap.updateNode(newInfo);
     LOG.info("Updated datanode {} {} to {} {}",
         oldInfo, oldInfo.getNodeStatus(), newInfo, newInfo.getNodeStatus());
     updateLastKnownVersionInfo(datanodeDetails, versionInfo);
+    if (clusterMap.getNode(newInfo.getNetworkFullPath()) != newInfo || 
clusterMap.contains(oldInfo)) {
+      LOG.info("The health check changed the network topology for {} during 
the update, updating it again", newInfo);
+      clusterMap.update(oldInfo, newInfo);

Review Comment:
   A delayed registration can run this repair after a newer registration 
completes, restoring the old replication port in topology while the node map 
retains the newer record.



-- 
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]

Reply via email to