{"record":{"id":"5f01b3f31b1cec3d","repo":"apache/iceberg","slug":"problem-reading-orc-file-s","errorCode":null,"errorMessage":"Problem reading ORC file %s","messagePattern":"Problem reading ORC file (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/VectorizedRowBatchIterator.java","lineNumber":60,"sourceCode":"  VectorizedRowBatchIterator(\n      String fileLocation, TypeDescription schema, RecordReader rows, int recordsPerBatch) {\n    this.fileLocation = fileLocation;\n    this.rows = rows;\n    this.batch = schema.createRowBatch(recordsPerBatch);\n  }\n\n  @Override\n  public void close() throws IOException {\n    rows.close();\n  }\n\n  private void advance() {\n    if (!advanced) {\n      try {\n        batchOffsetInFile = rows.getRowNumber();\n        rows.nextBatch(batch);\n      } catch (IOException ioe) {\n        throw new RuntimeIOException(ioe, \"Problem reading ORC file %s\", fileLocation);\n      }\n      advanced = true;\n    }\n  }\n\n  @Override\n  public boolean hasNext() {\n    advance();\n    return batch.size > 0;\n  }\n\n  @Override\n  public Pair<VectorizedRowBatch, Long> next() {\n    // make sure we have the next batch\n    advance();\n    // mark it as used\n    advanced = false;\n    return Pair.of(batch, batchOffsetInFile);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/VectorizedRowBatchIterator.java#L42-L78","documentation":"VectorizedRowBatchIterator lazily fetches the next ORC RowBatch in advance(). If the underlying ORC reader throws IOException while reading the next batch, it is wrapped in RuntimeIOException with the file location. This turns a checked I/O failure during scan into a runtime error for the iterator API.","triggerScenarios":"Calling hasNext() or next() on VectorizedRowBatchIterator when rows.nextBatch(batch) fails — corrupt/truncated ORC file, decompression failure, or storage (HDFS/S3) read errors mid-scan.","commonSituations":"Truncated files from failed writes; S3/HDFS network interruptions or throttling during long scans; checksum/corruption errors from object storage; file deleted or re-written concurrently while being scanned.","solutions":["Inspect the wrapped cause (ioe) to identify the storage-layer failure and fix it (network, permissions, throttling).","Verify file integrity; if truncated/corrupt, restore or rewrite the data file (e.g. Iceberg rewrite_data_files after fixing the source).","Retry the scan with engine-level retries; consider enabling Iceberg's task retry or re-running the failed Spark/Flink task.","If files are being deleted concurrently, ensure snapshot expiry/rewrite jobs don't remove files still needed by running queries."],"exampleFix":"// before: assuming the file is fine\nTableScan scan = table.newScan().planTasks();\n// after: validate/rescan on RuntimeIOException\ntry {\n  scan.planTasks();\n} catch (RuntimeIOException e) {\n  LOG.error(\"ORC read failed for {}: {}\", e.getFileLocation(), e.getCause());\n  // verify file exists/integrity, then retry or rewrite the file\n}","handlingStrategy":"retry","validationCode":"// Verify file readability before scanning\ntry (ORCFileReader r = new ORCFileReader(file.io().newInput(file.location()), ...)) {\n  Preconditions.checkArgument(r.rows() > 0 || file.recordCount() == 0);\n}","typeGuard":null,"tryCatchPattern":"try {\n  iterator.hasNext();\n} catch (RuntimeIOException e) {\n  LOG.error(\"ORC scan failed for {}\", e.getCause());\n  // inspect cause: S3Exception / EOFException etc., retry or fail task\n}","preventionTips":["Avoid querying files during snapshot expiry or rewrite jobs","Set storage client retries (S3/HDFS) for transient IO errors","Validate file integrity after copying/bulk-loading data"],"tags":["orc","io","corrupt-file"],"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"}