sodonnel commented on code in PR #3984:
URL: https://github.com/apache/ozone/pull/3984#discussion_r1029142931


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ECUnderReplicationHandler.java:
##########
@@ -158,96 +169,63 @@ public Map<DatanodeDetails, SCMCommand<?>> 
processAndCreateCommands(
     final ContainerID id = container.containerID();
     final Map<DatanodeDetails, SCMCommand<?>> commands = new HashMap<>();
     try {
-     // State is UNDER_REPLICATED
       final List<DatanodeDetails> deletionInFlight = new ArrayList<>();
       for (ContainerReplicaOp op : pendingOps) {
         if (op.getOpType() == ContainerReplicaOp.PendingOpType.DELETE) {
           deletionInFlight.add(op.getTarget());
         }
       }
-      List<Integer> missingIndexes = replicaCount.unavailableIndexes(true);
-      Map<Integer, Pair<ContainerReplica, NodeStatus>> sources =
-              filterSources(replicas, deletionInFlight);
-      List<DatanodeDetails> nodes =
-              sources.values().stream().map(Pair::getLeft)
-                      .map(ContainerReplica::getDatanodeDetails)
-                      .filter(datanodeDetails ->
-                              datanodeDetails.getPersistedOpState() ==
-                              HddsProtos.NodeOperationalState.IN_SERVICE)
-                      .collect(Collectors.toList());
-      // We got the missing indexes, this is excluded any decommissioning
-      // indexes. Find the good source nodes.
-      if (missingIndexes.size() > 0) {
 
-        LOG.debug("Missing indexes detected for the container {}." +
-                " The missing indexes are {}", id, missingIndexes);
-        // We have source nodes.
-        if (sources.size() >= repConfig.getData()) {
-          final List<DatanodeDetails> selectedDatanodes = getTargetDatanodes(
-              excludedNodes, container, missingIndexes.size());
-
-          if (validatePlacement(nodes, selectedDatanodes)) {
-            excludedNodes.addAll(selectedDatanodes);
-            nodes.addAll(selectedDatanodes);
-            List<ReconstructECContainersCommand.DatanodeDetailsAndReplicaIndex>
-                    sourceDatanodesWithIndex = new ArrayList<>();
-            for (Pair<ContainerReplica, NodeStatus> src : sources.values()) {
-              sourceDatanodesWithIndex.add(
-                      new ReconstructECContainersCommand
-                              .DatanodeDetailsAndReplicaIndex(
-                              src.getLeft().getDatanodeDetails(),
-                              src.getLeft().getReplicaIndex()));
-            }
+      Map<Integer, Pair<ContainerReplica, NodeStatus>> sources =
+          filterSources(replicas, deletionInFlight);
+      List<DatanodeDetails> availableSourceNodes =
+          sources.values().stream().map(Pair::getLeft)
+              .map(ContainerReplica::getDatanodeDetails)
+              .filter(datanodeDetails ->
+                  datanodeDetails.getPersistedOpState() ==
+                      HddsProtos.NodeOperationalState.IN_SERVICE)
+              .collect(Collectors.toList());
 
-            final ReconstructECContainersCommand reconstructionCommand =
-                    new 
ReconstructECContainersCommand(id.getProtobuf().getId(),
-                            sourceDatanodesWithIndex, selectedDatanodes,
-                            int2byte(missingIndexes),
-                            repConfig);
-            // Keeping the first target node as coordinator.
-            commands.put(selectedDatanodes.get(0), reconstructionCommand);
-          }
-        } else {
-          LOG.warn("Cannot proceed for EC container reconstruction for {}, due"
-              + " to insufficient source replicas found. Number of source "
-              + "replicas needed: {}. Number of available source replicas are:"
-              + " {}. Available sources are: {}", container.containerID(),
-              repConfig.getData(), sources.size(), sources);
+      try {
+        processMissingIndexes(replicaCount, sources, availableSourceNodes,
+            excludedNodes, commands);
+        processDecommissioningIndexes(replicaCount, replicas,
+            availableSourceNodes, excludedNodes, commands);
+        processMaintenanceOnlyIndexes(replicaCount, replicas, excludedNodes,
+            commands);
+        // TODO - we should be able to catch SCMException here and check the
+        //        result code but the RackAware topology never sets the code.
+      } catch (CannotFindTargetsException e) {
+        // If we get here, we tried to find nodes to fix the under replication

Review Comment:
   We don't stop two operations on a container being in flight at once, but we 
do track the inflight add / delete ops on a replica. So if two over rep 
operations were scheduled on the same container, they will have taken account 
of the pending ops and should do no harm.
   
   There is a change a delayed over rep command could impact an under-rep 
reconstruction by removing a replica it depends on, however the worst case is 
that the reconstruction fails and gets retried next time.
   
   This whole Jira is solve an edge case of under and over rep on a small 
cluster. I feel we can live with these other cases too, as they should be rare 
in practice and I think will only delay containers reaching their ideal state - 
they will not actually do any harm.



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