{"record":{"id":"090524ce3e1407d5","repo":"apache/iceberg","slug":"failed-to-close-task-iterable-090524","errorCode":null,"errorMessage":"Failed to close task iterable","messagePattern":"Failed to close task iterable","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/actions/BaseRewriteDataFilesAction.java","lineNumber":242,"sourceCode":"    }\n\n    long startingSnapshotId = table.currentSnapshot().snapshotId();\n    try {\n      fileScanTasks =\n          table\n              .newScan()\n              .useSnapshot(startingSnapshotId)\n              .caseSensitive(caseSensitive)\n              .ignoreResiduals()\n              .filter(filter)\n              .planFiles();\n    } finally {\n      try {\n        if (fileScanTasks != null) {\n          fileScanTasks.close();\n        }\n      } catch (IOException ioe) {\n        LOG.warn(\"Failed to close task iterable\", ioe);\n      }\n    }\n\n    Map<StructLikeWrapper, Collection<FileScanTask>> groupedTasks =\n        groupTasksByPartition(fileScanTasks.iterator());\n    Map<StructLikeWrapper, Collection<FileScanTask>> filteredGroupedTasks =\n        groupedTasks.entrySet().stream()\n            .filter(kv -> kv.getValue().size() > 1)\n            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));\n\n    // Nothing to rewrite if there's only one DataFile in each partition.\n    if (filteredGroupedTasks.isEmpty()) {\n      return RewriteDataFilesActionResult.empty();\n    }\n    // Split and combine tasks under each partition\n    List<CombinedScanTask> combinedScanTasks =\n        filteredGroupedTasks.values().stream()\n            .map(","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/actions/BaseRewriteDataFilesAction.java#L224-L260","documentation":"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.","triggerScenarios":"fileScanTasks.close() throws IOException during the finally block of execute(), typically because an underlying reader/input stream over data files cannot be closed cleanly.","commonSituations":"Object-store connection errors while closing read streams; underlying Hadoop FileSystem issues; interrupted IO during shutdown of the scan; flaky network to storage.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  rewriteAction.execute();\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException) {\n    LOG.warn(\"storage issue during rewrite; verify storage health and re-run\", e);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["io-error","resource-cleanup","rewrite"],"backgroundTag":"file-read-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}