xichen01 commented on code in PR #7031:
URL: https://github.com/apache/ozone/pull/7031#discussion_r1704335899


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java:
##########
@@ -424,14 +426,24 @@ private DeleteTransactionStats deleteTransactions(
       List<DeletedBlocksTransaction> delBlocks, Handler handler,
       Table<String, BlockData> blockDataTable, Container container)
       throws IOException {
+
     int blocksProcessed = 0;
     int blocksDeleted = 0;
     long bytesReleased = 0;
     List<DeletedBlocksTransaction> deletedBlocksTxs = new ArrayList<>();
     Instant startTime = Instant.now();
 
+    // Track deleted blocks to avoid duplicate deletion
+    Set<Long> deletedBlockSet = new HashSet<>();
+
     for (DeletedBlocksTransaction entry : delBlocks) {
       for (Long blkLong : entry.getLocalIDList()) {
+        // Check if the block has already been deleted
+        if (deletedBlockSet.contains(blkLong)) {

Review Comment:
   `blocksProcessed` need to be increased, because the `blocksProcessed` will 
be increase in the `DeleteBlocksCommandHandler` even the BlockID (different 
TransactionID) is duplicate



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java:
##########
@@ -424,14 +426,24 @@ private DeleteTransactionStats deleteTransactions(
       List<DeletedBlocksTransaction> delBlocks, Handler handler,
       Table<String, BlockData> blockDataTable, Container container)
       throws IOException {
+
     int blocksProcessed = 0;
     int blocksDeleted = 0;
     long bytesReleased = 0;
     List<DeletedBlocksTransaction> deletedBlocksTxs = new ArrayList<>();
     Instant startTime = Instant.now();
 
+    // Track deleted blocks to avoid duplicate deletion
+    Set<Long> deletedBlockSet = new HashSet<>();
+
     for (DeletedBlocksTransaction entry : delBlocks) {
       for (Long blkLong : entry.getLocalIDList()) {
+        // Check if the block has already been deleted
+        if (deletedBlockSet.contains(blkLong)) {

Review Comment:
   Could we add a metrics for this scenario?



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to