Skip to content

Commit

Permalink
Core: Fix missing delete files from transaction (#9354) (#9356)
Browse files Browse the repository at this point in the history
Co-authored-by: Fokko Driesprong <[email protected]>
  • Loading branch information
nastra and Fokko authored Dec 21, 2023
1 parent 63e0204 commit 9a5d24f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -884,6 +883,7 @@ public Object updateEvent() {
return new CreateSnapshotEvent(tableName, operation(), snapshotId, sequenceNumber, summary);
}

@SuppressWarnings("checkstyle:CyclomaticComplexity")
private void cleanUncommittedAppends(Set<ManifestFile> committed) {
if (cachedNewDataManifests != null) {
boolean hasDeletes = false;
Expand All @@ -899,15 +899,18 @@ private void cleanUncommittedAppends(Set<ManifestFile> committed) {
}
}

ListIterator<ManifestFile> deleteManifestsIterator = cachedNewDeleteManifests.listIterator();
while (deleteManifestsIterator.hasNext()) {
ManifestFile deleteManifest = deleteManifestsIterator.next();
if (!committed.contains(deleteManifest)) {
deleteFile(deleteManifest.path());
deleteManifestsIterator.remove();
boolean hasDeleteDeletes = false;
for (ManifestFile cachedNewDeleteManifest : cachedNewDeleteManifests) {
if (!committed.contains(cachedNewDeleteManifest)) {
deleteFile(cachedNewDeleteManifest.path());
hasDeleteDeletes = true;
}
}

if (hasDeleteDeletes) {
this.cachedNewDeleteManifests.clear();
}

// rewritten manifests are always owned by the table
for (ManifestFile manifest : rewrittenAppendManifests) {
if (!committed.contains(manifest)) {
Expand Down

0 comments on commit 9a5d24f

Please sign in to comment.