{"record":{"id":"d7fbe126b1a2d362","repo":"apache/iceberg","slug":"failed-to-close-changelog-scan-scan-d7fbe1","errorCode":null,"errorMessage":"Failed to close changelog scan: ${scan}","messagePattern":"Failed to close changelog scan: (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkChangelogScan.java","lineNumber":121,"sourceCode":"  @Override\n  public Batch toBatch() {\n    return new SparkBatch(\n        sparkContext,\n        table,\n        null != scan ? scan.fileIO() : table::io,\n        readConf,\n        EMPTY_GROUPING_KEY_TYPE,\n        taskGroups(),\n        projection,\n        hashCode());\n  }\n\n  private List<ScanTaskGroup<ChangelogScanTask>> taskGroups() {\n    if (taskGroups == null) {\n      try (CloseableIterable<ScanTaskGroup<ChangelogScanTask>> groups = scan.planTasks()) {\n        this.taskGroups = Lists.newArrayList(groups);\n      } catch (IOException e) {\n        throw new UncheckedIOException(\"Failed to close changelog scan: \" + scan, e);\n      }\n    }\n\n    return taskGroups;\n  }\n\n  @Override\n  public String description() {\n    return String.format(\n        Locale.ROOT,\n        \"IcebergChangelogScan(table=%s, fromSnapshotId=%d, toSnapshotId=%d, filters=%s)\",\n        table,\n        startSnapshotId,\n        endSnapshotId,\n        filtersDesc());\n  }\n\n  @Override","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkChangelogScan.java#L103-L139","documentation":"SparkChangelogScan.taskGroups wraps IOException raised while closing the CloseableIterable returned by scan.planTasks() in an UncheckedIOException. The scan planning itself succeeded, but closing the planning resources (manifest readers/file handles) failed.","triggerScenarios":"planTasks() iterable close() throws IOException during lazy task-group materialization of a changelog scan.","commonSituations":"Underlying FileIO (HDFS/S3) errors while releasing manifest readers; network interruption during close of open file handles; container-level cleanup failure.","solutions":["Inspect the chained IOException cause for the storage-level close failure","Check object store/filesystem health and retry the query","Use a more robust FileIO (e.g. S3FileIO with retries) if HDFS close failures recur","Report persistent close failures during planTasks to the Iceberg project"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { taskGroups() } catch (UncheckedIOException e) { log(e.getCause()); retry scan planning with backoff }","preventionTips":["Configure FileIO retry policies for HDFS/S3","Monitor storage layer health for streaming scans","Use S3FileIO with retry if HDFS close errors recur"],"tags":["spark","streaming","changelog","io"],"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-14T16:17:12.679Z"}