rdblue commented on a change in pull request #675: Inherit snapshot ids for 
manifest entries
URL: https://github.com/apache/incubator-iceberg/pull/675#discussion_r371481442
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java
 ##########
 @@ -381,9 +404,19 @@ private void cleanUncommittedAppends(Set<ManifestFile> 
committed) {
       this.cachedNewManifest = null;
     }
 
-    for (ManifestFile manifest : appendManifests) {
-      if (!committed.contains(manifest)) {
-        deleteFile(manifest.path());
+    // the clean-up logic depends on whether we append original manifests or 
their copies
+    // 1) if we rewrite manifests before appending them
+    //    we need to delete all uncommitted copies of manifests to prevent 
orphan metadata files
+    //    as the caller doesn't have access to them
+    // 2) if we append original manifests without rewriting them and the 
commit succeeds
+    //    we need to delete appended manifests that are merged with others 
while preparing a new snapshot
+    //    otherwise, the caller will have to find which appended manifests 
were merged but not committed
+    //    to prevent orphan metadata files
+    if (!snapshotIdInheritanceEnabled || !committed.isEmpty()) {
 
 Review comment:
   I think it would be easier to think about this if we kept owned manifests 
and non-owned manifests separate. Then we would be able to have the following 
logic here:
   
   ```java
     // appendManifests are rewritten and are owned by the table
     for (ManifestFile manifest : appendManifests) {
       if (!committed.contains(manifest)) {
         deleteFile(manifest.path());
       }
     }
   
     // inheritingManifests are only owned by the table if the commit succeeded
     if (!committed.isEmpty()) {
       // the commit succeeded if at least one manifest was committed
       // the table now owns the inheritingManifests; clean up any that are not 
used
       for (ManifestFile manifest : inheritingManifests) {
         if (!committed.contains(manifest)) {
           deleteFile(manifest.path());
         }
       }
     }
   ```
   
   @aokolnychyi, what do you think?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to