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


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java:
##########
@@ -313,20 +318,28 @@ private static void populateContainerMetadata(
 
     // Set pending deleted block count.
     final long blockPendingDeletion;
+    long blockPendingDeletionBytes = 0L;
+    Long pendingDeletionBlockBytes = metadataTable.get(kvContainerData
+        .getPendingDeleteBlockBytesKey());
     Long pendingDeleteBlockCount =
         metadataTable.get(kvContainerData
             .getPendingDeleteBlockCountKey());
     if (pendingDeleteBlockCount != null) {
       blockPendingDeletion = pendingDeleteBlockCount;
+      if (pendingDeletionBlockBytes != null) {
+        blockPendingDeletionBytes = pendingDeletionBlockBytes;
+      } else if 
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.DATA_DISTRIBUTION)) {
+        LOG.warn("Missing pendingDeletionSize from {}: recalculate them from  
delete txn tables",
+            metadataTable.getName());
+        ObjectNode pendingDeletions = getAggregateValues(store, 
kvContainerData, kvContainerData.getSchemaVersion());
+        blockPendingDeletionBytes = 
pendingDeletions.get(PENDING_DELETION_BYTES).asLong();
+      }
     } else {
-      // Set pending deleted block count.
-      LOG.warn("Missing pendingDeleteBlockCount from {}: recalculate them from 
block table", metadataTable.getName());
-      MetadataKeyFilters.KeyPrefixFilter filter =
-          kvContainerData.getDeletingBlockKeyFilter();
-      blockPendingDeletion = store.getBlockDataTable().getRangeKVs(
-          kvContainerData.startKeyEmpty(), Integer.MAX_VALUE, 
kvContainerData.containerPrefix(), filter, true)
-          // TODO: add a count() method to avoid creating a list
-          .size();
+      LOG.warn("Missing pendingDeleteBlockCount/size from {}: recalculate them 
from delete txn tables",
+          metadataTable.getName());
+      ObjectNode pendingDeletions = getAggregateValues(store, kvContainerData, 
kvContainerData.getSchemaVersion());
+      blockPendingDeletionBytes = 
pendingDeletions.get(PENDING_DELETION_BYTES).asLong();
+      blockPendingDeletion = 
pendingDeletions.get(PENDING_DELETION_BLOCKS).asLong();

Review Comment:
   The finalized check has been removed. As per Sammi's suggestion, this check 
and the related upgrade test cases will be addressed in a separate PR.



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