apache/iceberg · error
Interrupted while getting future results
Error message
Interrupted while getting future results
What it means
Tasks.waitFor() collects results of submitted futures once all complete; future.get() was interrupted while retrieving results. The interruption flag is restored, uncaught task exceptions are attached as suppressed, and a RuntimeException wraps the InterruptedException.
Solutions
- Identify who interrupted the thread (job cancellation, executor shutdown) and avoid cancelling while critical commits run
- Ensure the calling code does not shut down its executor while waitFor() is in flight
- Restore and respect the interrupt flag in your own wrappers — do not swallow InterruptedException
- If interruption is expected at shutdown, catch the RuntimeException and treat the operation as cancelled
Example fix
// before: shutting down pool then waiting on tasks pool.shutdown(); Tasks.foreach(item).executeWith(pool).run(); // after Tasks.foreach(item).executeWith(pool).run(); pool.shutdown();
Defensive patterns
Strategy: try-catch
Try / catch
try {
Tasks.foreach(items).executeWith(pool).run();
} catch (RuntimeException e) {
if (e.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt(); // restore flag; treat as cancellation
}
throw e;
} Prevention
- Do not shutdownNow() executors while Tasks.waitFor() is running
- Cancel jobs at safe boundaries between tasks
- Never swallow InterruptedException without restoring the interrupt flag
When it happens
Trigger: The thread running Tasks.waitFor(...) (e.g. a parallel commit/scan task driver) is interrupted while blocked in future.get() — typically by executor shutdown, task cancellation, or a parent job being cancelled (e.g. Spark/Flink job kill).
Common situations: Spark task cancellation during speculatively killed stages; JVM/executor shutdown while parallel file operations run; timeouts in upper layers that interrupt worker threads.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Interrupted while waiting for tasks to finish
- Interrupted in call to listTables
- Interrupted when waiting for deletions to complete
- Interrupted while polling queue
- Interrupted while waiting for array pool entry
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/6584503c1e75c958.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/util/Tasks.java:491
@SuppressWarnings("checkstyle:CyclomaticComplexity")
private static Collection<Throwable> waitFor(Collection<Future<?>> futures) {
while (true) {
int numFinished = 0;
for (Future<?> future : futures) {
if (future.isDone()) {
numFinished += 1;
}
}
if (numFinished == futures.size()) {
List<Throwable> uncaught = Lists.newArrayList();
// all of the futures are done, get any uncaught exceptions
for (Future<?> future : futures) {
try {
future.get();
} catch (InterruptedException e) {
LOG.warn("Interrupted while getting future results", e);
for (Throwable t : uncaught) {
e.addSuppressed(t);
}
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (CancellationException e) {
// ignore cancellations
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof Error) {
for (Throwable t : uncaught) {
cause.addSuppressed(t);
}
throw (Error) cause;
}
View on GitHub (pinned to 86d9c8fc54)