{"record":{"id":"5ac6ec55bc85995f","repo":"apache/iceberg","slug":"failed-to-close-manifest-s","errorCode":null,"errorMessage":"Failed to close manifest: %s","messagePattern":"Failed to close manifest: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/ManifestFiles.java","lineNumber":451,"sourceCode":"      EncryptedOutputFile outputFile,\n      long snapshotId,\n      SnapshotSummary.Builder summaryBuilder) {\n    // use metadata that will add the current snapshot's ID for the rewrite\n    // read first_row_id as null because this copies the incoming manifest before commit\n    InheritableMetadata inheritableMetadata = InheritableMetadataFactory.forCopy(snapshotId);\n    try (ManifestReader<DataFile> reader =\n        new ManifestReader<>(\n            toCopy, specId, specsById, inheritableMetadata, null, FileType.DATA_FILES)) {\n      return copyManifestInternal(\n          formatVersion,\n          null, // do not produce row IDs\n          reader,\n          outputFile,\n          snapshotId,\n          summaryBuilder,\n          ManifestEntry.Status.ADDED);\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to close manifest: %s\", toCopy.location());\n    }\n  }\n\n  static ManifestFile copyRewriteManifest(\n      int formatVersion,\n      int specId,\n      Long firstRowId,\n      InputFile toCopy,\n      Map<Integer, PartitionSpec> specsById,\n      EncryptedOutputFile outputFile,\n      long snapshotId,\n      SnapshotSummary.Builder summaryBuilder) {\n    // for a rewritten manifest all snapshot ids should be set. use empty metadata to throw an\n    // exception if it is not\n    InheritableMetadata inheritableMetadata = InheritableMetadataFactory.empty();\n    try (ManifestReader<DataFile> reader =\n        new ManifestReader<>(\n            toCopy, specId, specsById, inheritableMetadata, firstRowId, FileType.DATA_FILES)) {","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/ManifestFiles.java#L433-L469","documentation":"copyAppendManifest copies an existing manifest into a new output file and must close the manifest writer to flush AVRO data. If closing the writer's output stream raises IOException, it is wrapped in this RuntimeIOException naming the source manifest location. The copy itself failed at finalization, so the new manifest is not usable.","triggerScenarios":"Calling ManifestFiles.copyAppendManifest(...) during snapshot commit when the underlying OutputFile cannot be flushed/closed — e.g. storage backend failure, credentials expired mid-write, or network interruption to object storage.","commonSituations":"S3/GCS/HDFS transient failures during commit; expired cloud credentials; quota or rate limits on the object store; local disk full when writing to a file: location.","solutions":["Check the wrapped cause (e.getCause()) for the real storage error and fix storage connectivity/credentials","Retry the operation — manifest copies are idempotent per snapshot attempt","Verify sufficient disk/quota at the manifest output location"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify output location is writable before copying\nio.newInputFile(toCopy.location()).exists(); // source readable check\nFileIO finalIo = io; // ensure credentials are fresh for the duration","typeGuard":null,"tryCatchPattern":"try {\n  ManifestFile copied = ManifestFiles.copyAppendManifest(fv, specId, toCopy, io, outputFile, snapshotId, summaryBuilder);\n} catch (RuntimeIOException e) {\n  // inspect e.getCause(); transient storage errors are safe to retry\n  throw e;\n}","preventionTips":["Use retry with backoff around snapshot commits for transient storage errors","Keep cloud credentials valid for the full commit duration","Monitor object-store error rates during commit windows"],"tags":["io","file-write-failed","manifest-copy"],"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"}