priyeshkaratha commented on code in PR #11307:
URL: https://github.com/apache/ozone/pull/11307#discussion_r4324150282


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMDeletedBlockTransactionStatusManager.java:
##########
@@ -628,6 +664,63 @@ public void 
commitTransactions(List<DeleteBlockTransactionResult> transactionRes
     }
   }
 
+  private boolean hasPendingAddReplica(ContainerID containerId) {
+    return 
containerReplicaPendingOpsSupplier.get().getPendingOps(containerId).stream()
+        .anyMatch(op -> op.getOpType() == 
ContainerReplicaOp.PendingOpType.ADD);
+  }
+
+  /**
+   * Whether a transaction whose purge {@link #commitTransactions} deferred 
can be purged without another ACK:
+   * no replica ADD is in flight and every current replica has already 
committed it. A deferral caused only by
+   * an in-flight copy that later fails or expires is otherwise never retried, 
since no replica is left to ACK
+   * a resend and the entry would stay in {@link #transactionToDNsCommitMap} 
indefinitely.
+   */
+  boolean isPurgeableWithoutAck(long txID, ContainerID containerId) {
+    final Set<DatanodeID> committedDns = transactionToDNsCommitMap.get(txID);
+    if (committedDns == null || committedDns.isEmpty() || 
hasPendingAddReplica(containerId)) {
+      return false;
+    }
+    try {
+      final Set<ContainerReplica> replicas = 
containerManager.getContainerReplicas(containerId);
+      return !replicas.isEmpty()
+          && min(replicas.size(), committedDns.size())
+              >= 
containerManager.getContainer(containerId).getReplicationConfig().getRequiredNodes()
+          && replicas.stream().map(r -> 
r.getDatanodeDetails().getID()).allMatch(committedDns::contains);

Review Comment:
    Done. Purge now also requires the container to be HEALTHY, the same check 
getTransactions uses via checkInadequateReplica. This covers copies made for 
under-replication even when their ADD expires during a long import. HDDS-17152 
is left with only the case of a late copy registering after a replacement copy.



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