{"record":{"id":"48943d4626e2afbf","repo":"apache/iceberg","slug":"problem-writing-to-orc-file-s","errorCode":null,"errorMessage":"Problem writing to ORC file %s","messagePattern":"Problem writing to ORC file (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java","lineNumber":101,"sourceCode":"    OrcFile.WriterOptions options = OrcFile.writerOptions(conf).useUTCTimestamp(true);\n    if (file instanceof HadoopOutputFile) {\n      options.fileSystem(((HadoopOutputFile) file).getFileSystem());\n    }\n    options.setSchema(orcSchema);\n    this.writer = ORC.newFileWriter(file, options, metadata);\n    this.valueWriter = newOrcRowWriter(schema, orcSchema, createWriterFunc);\n  }\n\n  @Override\n  public void add(D datum) {\n    try {\n      valueWriter.write(datum, batch);\n      if (batch.size == this.batchSize) {\n        writer.addRowBatch(batch);\n        batch.reset();\n      }\n    } catch (IOException ioe) {\n      throw new UncheckedIOException(\n          String.format(\"Problem writing to ORC file %s\", file.location()), ioe);\n    }\n  }\n\n  @Override\n  public Metrics metrics() {\n    Preconditions.checkState(isClosed, \"Cannot return metrics while appending to an open file.\");\n    return OrcMetrics.fromWriter(writer, valueWriter.metrics(), metricsConfig);\n  }\n\n  @Override\n  public long length() {\n    if (isClosed) {\n      return file.toInputFile().getLength();\n    }\n\n    long estimateMemory = writer.estimateMemory();\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java#L83-L119","documentation":"OrcFileAppender.add writes each record into an ORC VectorizedRowBatch and flushes it to the underlying Writer via addRowBatch when full. Any IOException from that write path is wrapped in UncheckedIOException with the target file location and the original cause, since the append API is not checked-exception based.","triggerScenarios":"Calling appender.add(record) (or addAll) when the underlying ORC Writer fails to flush a row batch: disk full, filesystem/network errors (S3/HDFS interruptions), permission issues, or a record whose value fails ORC serialization inside the writer.","commonSituations":"Insufficient disk/quota on local or distributed storage while writing a large ORC file; transient cloud-storage failures; writing to a path the process lacks write permission for.","solutions":["Inspect the wrapped IOException cause for the storage-level problem (full disk, permission, throttling) and fix that underlying issue.","Check available disk space/quota on the target filesystem and free space or redirect output to a writable location.","Retry the write task; make the write idempotent so a partially written file is discarded and rewritten."],"exampleFix":"// before\ntry (FileAppender<Record> app = ORC.write(outputFile).schema(schema).build()) {\n  app.add(record); // UncheckedIOException: Problem writing to ORC file ...\n}\n// after: pre-check writable space/permissions and handle the cause\ntry (FileAppender<Record> app = ORC.write(outputFile).schema(schema).build()) {\n  app.add(record);\n} catch (UncheckedIOException e) {\n  LOG.error(\"ORC write failed for {}: {}\", e.getMessage(), e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight writable check\nif (!Files.getDefaultFileSystemProvider() /* or FS API */.getFileSystem(...).getUsed() /* capacity check */) {\n  throw new IllegalStateException(\"Insufficient space for ORC output\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  appender.add(record);\n} catch (UncheckedIOException e) {\n  Throwable cause = e.getCause(); // diagnose storage-level failure\n  LOG.error(\"ORC append failed: {} / {}\", e.getMessage(), cause.getMessage());\n  throw e;\n}","preventionTips":["Monitor disk/quota on the write target before large ORC writes","Ensure cloud storage credentials and network stability for the write path","Make write tasks idempotent so failed appends can be retried cleanly"],"tags":["java","orc","io","file-write"],"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-14T21:17:11.552Z"}