You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2020/09/15 17:07:01 UTC

[iceberg] branch master updated: Core: Fix ConcurrentModificationException in DeleteFileIndex (#1446)

This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new f710915  Core: Fix ConcurrentModificationException in DeleteFileIndex (#1446)
f710915 is described below

commit f71091539e1fa9e4064cfbc5141fe3e890e1a5f0
Author: Ryan Blue <bl...@apache.org>
AuthorDate: Tue Sep 15 10:05:27 2020 -0700

    Core: Fix ConcurrentModificationException in DeleteFileIndex (#1446)
---
 .../main/java/org/apache/iceberg/DeleteFileIndex.java   |  2 +-
 .../java/org/apache/iceberg/util/ParallelIterable.java  | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/iceberg/DeleteFileIndex.java b/core/src/main/java/org/apache/iceberg/DeleteFileIndex.java
index 4742cc8..ec8d2fe 100644
--- a/core/src/main/java/org/apache/iceberg/DeleteFileIndex.java
+++ b/core/src/main/java/org/apache/iceberg/DeleteFileIndex.java
@@ -76,7 +76,7 @@ class DeleteFileIndex {
     ImmutableMap.Builder<Integer, Types.StructType> builder = ImmutableMap.builder();
     specsById.forEach((specId, spec) -> builder.put(specId, spec.partitionType()));
     this.partitionTypeById = builder.build();
-    this.wrapperById = Maps.newHashMap();
+    this.wrapperById = Maps.newConcurrentMap();
     this.globalSeqs = globalSeqs;
     this.globalDeletes = globalDeletes;
     this.sortedDeletesByPartition = sortedDeletesByPartition;
diff --git a/core/src/main/java/org/apache/iceberg/util/ParallelIterable.java b/core/src/main/java/org/apache/iceberg/util/ParallelIterable.java
index 3e46c02..3afc1c9 100644
--- a/core/src/main/java/org/apache/iceberg/util/ParallelIterable.java
+++ b/core/src/main/java/org/apache/iceberg/util/ParallelIterable.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import org.apache.iceberg.exceptions.RuntimeIOException;
@@ -98,6 +99,22 @@ public class ParallelIterable<T> extends CloseableGroup implements CloseableIter
 
       for (int i = 0; i < taskFutures.length; i += 1) {
         if (taskFutures[i] == null || taskFutures[i].isDone()) {
+          if (taskFutures[i] != null) {
+            // check for task failure and re-throw any exception
+            try {
+              taskFutures[i].get();
+            } catch (ExecutionException e) {
+              if (e.getCause() instanceof RuntimeException) {
+                // rethrow a runtime exception
+                throw (RuntimeException) e.getCause();
+              } else {
+                throw new RuntimeException("Failed while running parallel task", e.getCause());
+              }
+            } catch (InterruptedException e) {
+              throw new RuntimeException("Interrupted while running parallel task", e);
+            }
+          }
+
           taskFutures[i] = submitNextTask();
         }