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


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMDeletedBlockTransactionStatusManager.java:
##########
@@ -467,17 +465,37 @@ public void 
addTransactions(ArrayList<DeletedBlocksTransaction> txList) throws I
           incrDeletedBlocksSummary(tx);
         }
       }
-      deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
+      try {
+        deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
+      } catch (IOException e) {
+        // Revert the in-memory changes if the DB update fails
+        for (DeletedBlocksTransaction tx: txList) {
+          if (tx.hasTotalBlockSize()) {
+            descDeletedBlocksSummary(tx);
+            LOG.warn("{} is decreased from summary due to DB update failure", 
transactionToString(tx));
+          }
+        }
+        throw e;
+      }
       return;
     }
     deletedBlockLogStateManager.addTransactionsToDB(txList);
   }
 
+  private void incrDeletedBlocksSummary(TxBlockInfo txBlockInfo) {

Review Comment:
   since this method is used to do rollback, can we rename to something like 
restoreDeletedBlocksSummary



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