ConeyLiu commented on code in PR #6335:
URL: https://github.com/apache/iceberg/pull/6335#discussion_r1039689716


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -838,9 +839,17 @@ public Object updateEvent() {
   }
 
   private void cleanUncommittedAppends(Set<ManifestFile> committed) {
-    if (cachedNewManifest != null && !committed.contains(cachedNewManifest)) {
-      deleteFile(cachedNewManifest.path());
-      this.cachedNewManifest = null;
+    if (cachedNewManifests != null) {
+      List<ManifestFile> cleanedNewManifests = Lists.newArrayList();
+      for (ManifestFile manifestFile : cachedNewManifests) {
+        if (!committed.contains(manifestFile)) {
+          deleteFile(manifestFile.path());
+        } else {
+          cleanedNewManifests.add(manifestFile);
+        }
+      }
+
+      this.cachedNewManifests = cleanedNewManifests;

Review Comment:
   From the failed UTs, it seems it could call the `cleanUncommittedAppends` 
multiple times when retrying the commit. And we need to make sure the previous 
wroten manifest file is deleted.



##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -948,13 +949,10 @@ private List<ManifestFile> newDeleteFilesAsManifests() {
           (specId, deleteFiles) -> {
             PartitionSpec spec = ops.current().spec(specId);
             try {
-              ManifestWriter<DeleteFile> writer = 
newDeleteManifestWriter(spec);
-              try {
-                writer.addAll(deleteFiles);
-              } finally {
-                writer.close();
-              }
-              cachedNewDeleteManifests.add(writer.toManifestFile());
+              List<ManifestFile> manifestFiles =

Review Comment:
   updated



-- 
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-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to