ebyhr commented on code in PR #19204:
URL: https://github.com/apache/iceberg/pull/19204#discussion_r4734802393


##########
core/src/test/java/org/apache/iceberg/TestRemoveSnapshots.java:
##########
@@ -2214,6 +2214,58 @@ void 
expireDeletesPuffinFileWhenAllSharedDeletionVectorsReplaced() {
     assertThat(deletedFiles).contains(sharedPuffinPath);
   }
 
+  @TestTemplate
+  void expireKeepsSharedPuffinFileWhenRetainedManifestListUnreadable() {
+    assumeThat(formatVersion).as("Deletion vectors require V3 or 
later").isGreaterThanOrEqualTo(3);
+    assumeThat(incrementalCleanup).isTrue();
+
+    table.newAppend().appendFile(FILE_A).appendFile(FILE_B).commit();
+
+    String sharedPuffinPath = "/path/to/shared-dvs-" + UUID.randomUUID() + 
".puffin";
+    DeleteFile dvA = deletionVector(sharedPuffinPath, FILE_A, 4L);
+    DeleteFile dvB = deletionVector(sharedPuffinPath, FILE_B, 44L);
+    table.newRowDelta().addDeletes(dvA).addDeletes(dvB).commit();
+
+    // replacing dvA expires; dvB stays live in the shared file for the 
retained snapshot
+    DeleteFile newDvA =
+        deletionVector("/path/to/new-dv-a-" + UUID.randomUUID() + ".puffin", 
FILE_A, 4L);
+    table
+        .newRowDelta()
+        .validateFromSnapshot(table.currentSnapshot().snapshotId())
+        .removeDeletes(dvA)
+        .addDeletes(newDvA)
+        .commit();
+
+    table.newAppend().appendFile(FILE_C).commit();
+    Snapshot retained = table.currentSnapshot();
+
+    // only a later snapshot stops referencing dvB
+    DeleteFile newDvB =
+        deletionVector("/path/to/new-dv-b-" + UUID.randomUUID() + ".puffin", 
FILE_B, 4L);
+    table
+        .newRowDelta()
+        .validateFromSnapshot(retained.snapshotId())
+        .removeDeletes(dvB)
+        .addDeletes(newDvB)
+        .commit();
+
+    long tAfterCommits = 
waitUntilAfter(table.currentSnapshot().timestampMillis());
+
+    table.io().deleteFile(retained.manifestListLocation());
+
+    Set<String> deletedFiles = Sets.newHashSet();
+    removeSnapshots(table)
+        .retainLast(2)
+        .expireOlderThan(tAfterCommits)
+        .deleteWith(deletedFiles::add)
+        .commit();
+
+    assertThat(table.snapshot(retained.snapshotId())).isNotNull();
+    assertThat(deletedFiles)
+        .as("Puffin file must be kept when live deletion vectors cannot be 
determined")
+        .doesNotContain(sharedPuffinPath);

Review Comment:
   This assertion fails if we revert this PR:
   ```
   java.lang.AssertionError: [Puffin file must be kept when live deletion 
vectors cannot be determined] 
   Expecting
     
["/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/junit-4226703397745214989/metadata/c7fbdd11-77a9-47eb-abf7-6429b23b8b53-m0.avro",
       
"/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/junit-4226703397745214989/metadata/snap-1-1-ad57a407-383c-4ad5-ac89-79b5d7a3171e.avro",
       
"/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/junit-4226703397745214989/metadata/snap-2-1-322da627-3a8e-468f-8fa1-331a5c9dfe27.avro",
       
"/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/junit-4226703397745214989/metadata/322da627-3a8e-468f-8fa1-331a5c9dfe27-m0.avro",
       
"/var/folders/9s/_zwn4r_n2_9bp0krllp1pl3c0000gp/T/junit-4226703397745214989/metadata/snap-3-1-c7fbdd11-77a9-47eb-abf7-6429b23b8b53.avro",
       "/path/to/shared-dvs-142fa9db-12d2-4410-a2b7-385c7ee98a52.puffin"]
   not to contain
     ["/path/to/shared-dvs-142fa9db-12d2-4410-a2b7-385c7ee98a52.puffin"]
   but found
     ["/path/to/shared-dvs-142fa9db-12d2-4410-a2b7-385c7ee98a52.puffin"]
   ```



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