apache/iceberg · warning
Failed to close task iterable
Error message
Failed to close task iterable
What it means
In BaseRewriteDataFilesAction.execute(), the iterable of FileScanTasks produced during planning is closed in a finally block. If closing throws an IOException, this warning is logged. The rewrite proceeds — the warning only reports failure to release underlying resources (e.g. open file handles) held by the task iterable.
Solutions
- Inspect the logged IOException's cause for the underlying storage problem.
- Verify storage connectivity/permissions and object-store health at close time.
- Re-run the rewrite action after storage issues are resolved — the warning usually doesn't block the rewrite itself.
- If reproducible, check for leaked/closed-twice streams in custom FileIO implementations.
Defensive patterns
Strategy: try-catch
Try / catch
try {
rewriteAction.execute();
} catch (RuntimeException e) {
if (e.getCause() instanceof IOException) {
LOG.warn("storage issue during rewrite; verify storage health and re-run", e);
}
throw e;
} Prevention
- Ensure stable connectivity to the object store
- Verify FileIO implementations close streams correctly once
- Check storage permissions for read/close operations
- Re-run actions after transient storage errors
When it happens
Trigger: fileScanTasks.close() throws IOException during the finally block of execute(), typically because an underlying reader/input stream over data files cannot be closed cleanly.
Common situations: Object-store connection errors while closing read streams; underlying Hadoop FileSystem issues; interrupted IO during shutdown of the scan; flaky network to storage.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Failed to close task iterator
- Cannot commit rewrite because of a ValidationException or…
- Commit operation did not complete within
- Commit state unknown, cannot clean up files that may have…
- does not support altering tables
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/090524ce3e1407d5.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/actions/BaseRewriteDataFilesAction.java:242
}
long startingSnapshotId = table.currentSnapshot().snapshotId();
try {
fileScanTasks =
table
.newScan()
.useSnapshot(startingSnapshotId)
.caseSensitive(caseSensitive)
.ignoreResiduals()
.filter(filter)
.planFiles();
} finally {
try {
if (fileScanTasks != null) {
fileScanTasks.close();
}
} catch (IOException ioe) {
LOG.warn("Failed to close task iterable", ioe);
}
}
Map<StructLikeWrapper, Collection<FileScanTask>> groupedTasks =
groupTasksByPartition(fileScanTasks.iterator());
Map<StructLikeWrapper, Collection<FileScanTask>> filteredGroupedTasks =
groupedTasks.entrySet().stream()
.filter(kv -> kv.getValue().size() > 1)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// Nothing to rewrite if there's only one DataFile in each partition.
if (filteredGroupedTasks.isEmpty()) {
return RewriteDataFilesActionResult.empty();
}
// Split and combine tasks under each partition
List<CombinedScanTask> combinedScanTasks =
filteredGroupedTasks.values().stream()
.map(View on GitHub (pinned to 86d9c8fc54)