szetszwo commented on code in PR #4337:
URL: https://github.com/apache/ozone/pull/4337#discussion_r1135199380


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerMetadataInspector.java:
##########
@@ -392,6 +412,38 @@ private boolean checkAndRepair(JsonObject parent,
       errors.add(usedBytesError);
     }
 
+    // check and repair if db delete count mismatches delete transaction count.
+    final JsonElement dbDeleteCountJson = dBMetadata.get(
+        OzoneConsts.PENDING_DELETE_BLOCK_COUNT);
+    final long dbDeleteCount = jsonToLong(dbDeleteCountJson);
+    final JsonElement deleteTxCountJson = aggregates.get(PendingDelete.COUNT);
+    final long deleteTransactionCount = jsonToLong(deleteTxCountJson);
+    if (dbDeleteCount != deleteTransactionCount) {
+      passed = false;
+
+      final BooleanSupplier deleteCountRepairAction = () -> {
+        if (deleteTransactionCount == 0) {
+          // repair only when delete transaction count is 0
+          final String key = containerData.getPendingDeleteBlockCountKey();
+          try {
+            // reset delete block count to 0 in metadata table
+            metadataTable.put(key, 0L);
+            return true;
+          } catch (IOException ex) {
+            LOG.error("Failed to reset {} for container {}.",
+                key, containerData.getContainerID(), ex);
+          }
+        }
+        return false;
+      };
+
+      final JsonObject deleteCountError = buildErrorAndRepair(
+          "dBMetadata." + OzoneConsts.PENDING_DELETE_BLOCK_COUNT,
+          dbDeleteCountJson, deleteTxCountJson,

Review Comment:
   The test will fail if we swap them.  Let me take a look.



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