sreejasahithi commented on code in PR #10105:
URL: https://github.com/apache/ozone/pull/10105#discussion_r3121767076


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -169,12 +169,45 @@ private DeletedBlocksTransaction constructNewTransaction(
       // even when HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION is finalized, 
old OM can still call the old API
       if (replicatedSize >= 0) {
         builder.setTotalBlockReplicatedSize(replicatedSize);
-        
builder.setTotalBlockSize(blocks.stream().mapToLong(DeletedBlock::getSize).sum());
+        builder.setTotalBlockSize(computePerReplicaBlockSize(containerID, 
replicatedSize, blocks));
       }
     }
     return builder.build();
   }
 
+  /**
+   * Computes the per-replica block size for a delete transaction.
+   *
+   * <p>Each DN replica receives the same {@link DeletedBlocksTransaction} and
+   * increments its local pending-deletion byte counter by
+   * {@code totalBlockSize}. DN then sums these counters across all replicas.
+   * To make that sum equal the total physical bytes being freed
+   * ({@code totalBlockReplicatedSize}), each replica must track
+   * {@code totalBlockReplicatedSize / replicationFactor}.
+   *
+   * <p>For Ratis(N) this is algebraically identical to the logical block size
+   * (no change in behaviour). For EC(k+m) it corrects the previous k+m-fold
+   * over-count.
+   */
+  private long computePerReplicaBlockSize(long containerID, long 
replicatedSize,
+      List<DeletedBlock> blocks) {
+    if (replicatedSize > 0) {
+      try {
+        int requiredNodes = containerManager

Review Comment:
   Here the check should also be `>= 0` for `replicatedSize`.
   If `replicatedSize` is 0, the caller (`constructNewTransaction`) allows the 
process to continue since 0 >= 0 is true. However, inside 
computePerReplicaBlockSize, the condition `if (replicatedSize > 0)` evaluates 
to false. The code then skips the division logic and executes the fallback, 
returning the logical block size sum instead of 0. This is inconsistent when 
`replicatedSize == 0`, the per-replica size should also be 0 (i.e. 0 / 
requiredNodes), not the logical sum.



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