smengcl commented on code in PR #10750:
URL: https://github.com/apache/ozone/pull/10750#discussion_r3643946571


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -1354,6 +1355,53 @@ private String resolveBucketRelativePath(boolean 
isFSOBucket,
         .substring(1);
   }
 
+  /**
+   * Returns whether any ancestor of the given parent is a deleted directory.
+   */
+  @VisibleForTesting
+  boolean hasDeletedAncestor(long parentObjectId, Set<Long> 
deletedDirectoryIds,
+      Map<Long, Long> objectIdToParentId, long bucketObjectId) {
+    long currentParent = parentObjectId;
+    while (currentParent != bucketObjectId) {
+      if (deletedDirectoryIds.contains(currentParent)) {
+        return true;
+      }
+      Long nextParent = objectIdToParentId.get(currentParent);
+      if (nextParent == null) {
+        throw new IllegalStateException(
+            "Missing parent for object ID: " + currentParent);
+      }
+      currentParent = nextParent;

Review Comment:
   If `A/B` is renamed to `C/B`,
   `A/B/file` is deleted,
   and `A` is deleted,
   then `deletedDirectoryIds` contains `A` but not the surviving directory `B`.
   
   This walk continues through `B`,
   finds deleted `A`,
   and filters out the DELETE for `file`.
   
   Replaying the remaining entries can then rename `B` with `file` still inside 
it,
   leaving `C/B/file` behind.
   
   An ancestor DELETE does not make a descendant DELETE redundant
   when an intervening directory survives through a rename.
   
   Please retain the descendant DELETE in this case
   and add a test for it.



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