ChenSammi commented on code in PR #8827:
URL: https://github.com/apache/ozone/pull/8827#discussion_r2259470068


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java:
##########
@@ -621,26 +621,34 @@ private void updateMetaData(KeyValueContainerData 
containerData,
       Table<String, Long> metadataTable =
           containerDB.getStore().getMetadataTable();
 
-      // In memory is updated only when existing delete transactionID is
-      // greater.
-      if (delTX.getTxID() > containerData.getDeleteTransactionId()) {
-        // Update in DB pending delete key count and delete transaction ID.
+      // Synchronize on containerData to prevent concurrent updates
+      synchronized (containerData) {
+        // In memory is updated only when existing delete transactionID is
+        // greater.
+        if (delTX.getTxID() > containerData.getDeleteTransactionId()) {
+          // Update in DB pending delete key count and delete transaction ID.
+          metadataTable
+              .putWithBatch(batchOperation,
+                  containerData.getLatestDeleteTxnKey(), delTX.getTxID());
+        }
+
+        long pendingDeleteBlocks =
+            containerData.getNumPendingDeletionBlocks() + newDeletionBlocks;
         metadataTable
             .putWithBatch(batchOperation,
-                containerData.getLatestDeleteTxnKey(), delTX.getTxID());
+                containerData.getPendingDeleteBlockCountKey(),
+                pendingDeleteBlocks);
+
+        // update pending deletion blocks count and delete transaction ID in
+        // in-memory container status
+        long pendingBytes = delTX.getTotalBlockSize();
+        containerData.updateDeleteTransactionId(delTX.getTxID());

Review Comment:
   updateDeleteTransactionId should only be called if 
   
   delTX.getTxID() > containerData.getDeleteTransactionId()



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