Skip to content

Commit

Permalink
Core: Fix missing delete files from transaction (apache#9354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko authored and lisirrx committed Jan 4, 2024
1 parent 438de7d commit 16cbb71
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 @@ -27,7 +27,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 @@ -877,6 +876,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 @@ -892,15 +892,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 16cbb71

Please sign in to comment.