You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "hemantk-12 (via GitHub)" <gi...@apache.org> on 2024/09/06 18:13:31 UTC

Re: [PR] HDDS-11244. Draft PR to address multiple issues in garbage collection. Will split it into multiple PRs [ozone]

hemantk-12 commented on code in PR #7097:
URL: https://github.com/apache/ozone/pull/7097#discussion_r1746544074


##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -1990,12 +2000,18 @@ message SnapshotPurgeRequest {
   repeated string updatedSnapshotDBKey = 2 [deprecated = true];
 }
 
+message SnapshotPurgeAndMoveRequest {
+  required hadoop.hdds.UUID snapshotID = 1;

Review Comment:
   nit: Protobuf suggests not use required from proto-3
   https://protobuf.dev/programming-guides/dos-donts/#add-required



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/TransactionInfo.java:
##########
@@ -162,7 +162,16 @@ public String toString() {
    */
   public static TransactionInfo readTransactionInfo(
       DBStoreHAManager metadataManager) throws IOException {
-    return metadataManager.getTransactionInfoTable().get(TRANSACTION_INFO_KEY);
+    return readTransactionInfo(metadataManager, false);
+  }
+
+  /**
+   * Return transaction info persisted in OM DB skipping cache.
+   */
+  public static TransactionInfo readTransactionInfo(

Review Comment:
   Do we really need to read it from DB? It gets flushed to DB as part of the same batch transaction. https://github.com/apache/ozone/blob/7a452ca2e84520c2fb15356fde38857cacb758c5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java#L359-L362 



##########
hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java:
##########
@@ -116,6 +116,22 @@ public interface OMMetadataManager extends DBStoreHAManager {
    */
   String getBucketKey(String volume, String bucket);
 
+  /**
+   * Given a volume and bucket, return the corresponding DB key prefix.
+   *
+   * @param volume - User name
+   * @param bucket - Bucket name
+   */
+  String getBucketKeyPrefix(String volume, String bucket);

Review Comment:
   We have similar functions in [SnapshotUtils](https://github.com/apache/ozone/blob/7a452ca2e84520c2fb15356fde38857cacb758c5/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java#L202-L244). Can you please move them from here?



##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -1990,12 +2000,18 @@ message SnapshotPurgeRequest {
   repeated string updatedSnapshotDBKey = 2 [deprecated = true];
 }
 
+message SnapshotPurgeAndMoveRequest {

Review Comment:
   Don't you need to add it in [Type](https://github.com/apache/ozone/blob/7a452ca2e84520c2fb15356fde38857cacb758c5/hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto#L41)?



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyDeletingService.java:
##########
@@ -174,6 +183,113 @@ public void setKeyLimitPerTask(int keyLimitPerTask) {
    */
   private class KeyDeletingTask implements BackgroundTask {
 
+    private OzoneManagerProtocolProtos.SetSnapshotPropertyRequest getSetSnapshotRequestUpdatingExclusiveSize(
+        Map<String, Long> exclusiveSizeMap, Map<String, Long> exclusiveReplicatedSizeMap, String prevSnapshotKeyTable) {
+      OzoneManagerProtocolProtos.SnapshotSize snapshotSize = OzoneManagerProtocolProtos.SnapshotSize.newBuilder()
+          .setExclusiveSize(
+              exclusiveSizeMap.getOrDefault(prevSnapshotKeyTable, 0L))
+          .setExclusiveReplicatedSize(
+              exclusiveReplicatedSizeMap.getOrDefault(
+                  prevSnapshotKeyTable, 0L))
+          .build();
+      exclusiveSizeMap.remove(prevSnapshotKeyTable);
+      exclusiveReplicatedSizeMap.remove(prevSnapshotKeyTable);
+
+      return OzoneManagerProtocolProtos.SetSnapshotPropertyRequest.newBuilder()
+          .setSnapshotKey(prevSnapshotKeyTable)
+          .setSnapshotSize(snapshotSize)
+          .build();
+    }
+
+    private OzoneManagerProtocolProtos.SetSnapshotPropertyRequest
+    getSetSnapshotPropertyRequestupdatingDeepCleanSnapshotDir(String snapshotKeyTable) {
+      return OzoneManagerProtocolProtos.SetSnapshotPropertyRequest.newBuilder()
+          .setSnapshotKey(snapshotKeyTable)
+          .setDeepCleanedDeletedKey(true)
+          .build();
+    }
+
+    private void submitSetSnapshotRequest(
+        List<OzoneManagerProtocolProtos.SetSnapshotPropertyRequest> setSnapshotPropertyRequests) {
+      OzoneManagerProtocolProtos.OMRequest omRequest = OzoneManagerProtocolProtos.OMRequest.newBuilder()
+          .setCmdType(OzoneManagerProtocolProtos.Type.SetSnapshotProperty)
+          .addAllSetSnapshotPropertyRequests(setSnapshotPropertyRequests)
+          .setClientId(clientId.toString())
+          .build();
+      submitRequest(omRequest, clientId);
+    }
+
+
+    /**
+     *
+     * @param currentSnapshotInfo if null, deleted directories in AOS should be processed.
+     * @param keyManager KeyManager of the underlying store.
+     */
+    private int processDeletedKeysForStore(SnapshotInfo currentSnapshotInfo, KeyManager keyManager,
+                                            int remainNum) throws IOException {
+      String volume = currentSnapshotInfo == null ? null : currentSnapshotInfo.getVolumeName();
+      String bucket = currentSnapshotInfo == null ? null : currentSnapshotInfo.getBucketName();
+      String snapshotTableKey = currentSnapshotInfo == null ? null : currentSnapshotInfo.getTableKey();
+      String startKey = "";
+      int initialRemainNum = remainNum;
+      boolean successStatus = true;
+      try {
+        // TODO: [SNAPSHOT] HDDS-7968. Reclaim eligible key blocks in
+        //  snapshot's deletedTable when active DB's deletedTable
+        //  doesn't have enough entries left.
+        //  OM would have to keep track of which snapshot the key is coming
+        //  from if the above would be done inside getPendingDeletionKeys().
+        OmSnapshotManager omSnapshotManager = getOzoneManager().getOmSnapshotManager();
+        SnapshotChainManager snapshotChainManager = ((OmMetadataManagerImpl)getOzoneManager().getMetadataManager())
+            .getSnapshotChainManager();
+        IOzoneManagerLock lock = getOzoneManager().getMetadataManager().getLock();
+
+        ReclaimableKeyFilter reclaimableKeyFilter = new ReclaimableKeyFilter(omSnapshotManager, snapshotChainManager,
+            currentSnapshotInfo, keyManager.getMetadataManager(), lock);
+        ReclaimableRenameEntryFilter renameEntryFilter = new ReclaimableRenameEntryFilter(
+            omSnapshotManager, snapshotChainManager, currentSnapshotInfo, keyManager.getMetadataManager(), lock);
+        List<Table.KeyValue<String, String>> renamedTableEntries = keyManager.getRenamesKeyEntries(volume, bucket,
+            startKey, renameEntryFilter, remainNum);
+        submitPurgeKeysRequest()

Review Comment:
   Incomplete and invalid line.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotInfo.java:
##########
@@ -124,6 +126,7 @@ public static SnapshotStatus valueOf(SnapshotStatusProto status) {
   private long exclusiveSize;
   private long exclusiveReplicatedSize;
   private boolean deepCleanedDeletedDir;
+  private ByteString lastTransactionInfo;

Review Comment:
   Why does it has to be ByteString? Is it for `toString()`? You can simply keep it as `TransactionInfo`. Rather than converting it later in  `OmSnapshotManager`.



##########
hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java:
##########
@@ -116,6 +116,22 @@ public interface OMMetadataManager extends DBStoreHAManager {
    */
   String getBucketKey(String volume, String bucket);
 
+  /**
+   * Given a volume and bucket, return the corresponding DB key prefix.
+   *
+   * @param volume - User name

Review Comment:
   1. Volume Name not user name.
   2. Please either write a better Java doc or don't write it. There is no difference between this and next function's description. 



##########
hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/OMMetadataManager.java:
##########
@@ -116,6 +116,22 @@ public interface OMMetadataManager extends DBStoreHAManager {
    */
   String getBucketKey(String volume, String bucket);
 
+  /**
+   * Given a volume and bucket, return the corresponding DB key prefix.
+   *
+   * @param volume - User name
+   * @param bucket - Bucket name
+   */
+  String getBucketKeyPrefix(String volume, String bucket);
+
+  /**
+   * Given a volume and bucket, return the corresponding DB key prefix.
+   *
+   * @param volume - User name

Review Comment:
   Volume Name not user name.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java:
##########
@@ -112,6 +112,9 @@ public enum ResultCodes {
     FAILED_TO_FIND_CONTAINER,
     FAILED_TO_FIND_CONTAINER_WITH_SPACE,
     BLOCK_EXISTS,
+    //OM can send a deleteBlockRequest for key delete more than once. Thus, it shouldn't

Review Comment:
   Please remove this from the change as well.



-- 
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-unsubscribe@ozone.apache.org

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


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