{"record":{"id":"e5a29bf40c930252","repo":"apache/iceberg","slug":"failed-to-close-current-writer","errorCode":null,"errorMessage":"Failed to close current writer","messagePattern":"Failed to close current writer","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/RollingManifestWriter.java","lineNumber":133,"sourceCode":"    }\n\n    return currentWriter;\n  }\n\n  private boolean shouldRollToNewFile() {\n    return currentFileRows % ROWS_DIVISOR == 0 && currentWriter.length() >= targetFileSizeInBytes;\n  }\n\n  private void closeCurrentWriter() {\n    if (currentWriter != null) {\n      try {\n        currentWriter.close();\n        ManifestFile currentFile = currentWriter.toManifestFile();\n        manifestFiles.add(currentFile);\n        this.currentWriter = null;\n        this.currentFileRows = 0;\n      } catch (IOException e) {\n        throw new UncheckedIOException(\"Failed to close current writer\", e);\n      }\n    }\n  }\n\n  @Override\n  public void close() throws IOException {\n    if (!closed) {\n      closeCurrentWriter();\n      this.closed = true;\n    }\n  }\n\n  public List<ManifestFile> toManifestFiles() {\n    Preconditions.checkState(closed, \"Cannot get ManifestFile list from unclosed writer\");\n    return manifestFiles;\n  }\n}\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/RollingManifestWriter.java#L115-L151","documentation":"RollingManifestWriter.closeCurrentWriter wraps an IOException from closing the current manifest writer in an UncheckedIOException. This means the underlying manifest file could not be flushed/closed (I/O failure to the file store), so the manifest being rolled may be incomplete.","triggerScenarios":"currentWriter or close triggers a manifest writer close that throws IOException — underlying storage failure, network interruption, quota/full disk, or permissions problem on the manifest output location.","commonSituations":"S3/HDFS transient failures during commit; credential expiry mid-write; disk full; concurrent deletion of the output file.","solutions":["Inspect the chained IOException cause for the storage-level failure and address it (credentials, connectivity, quota).","Retry the operation; the failed manifest is discarded since it was never committed.","Verify write permissions and available space on the table's write location."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (RollingManifestWriter w = new RollingManifestWriter(...)) { ... } catch (UncheckedIOException e) {\n  LOG.error(\"manifest close failed\", e.getCause());\n  throw e;\n}","preventionTips":["Check storage health/credentials before large commits","Ensure sufficient disk/quota on the write location","Retry failed commits; uncommitted manifests are discarded"],"tags":["iceberg","io","manifest-writer","unchecked-exception"],"backgroundTag":"file-write-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"}