{"record":{"id":"cd3af302d73b8688","repo":"apache/iceberg","slug":"failed-to-read-next-record","errorCode":null,"errorMessage":"Failed to read next record","messagePattern":"Failed to read next record","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroIterable.java","lineNumber":162,"sourceCode":"    }\n\n    @Override\n    public D next() {\n      if (!hasNext()) {\n        throw new NoSuchElementException();\n      }\n      return reader.next();\n    }\n\n    @Override\n    public D next(D reuse) {\n      if (!hasNext()) {\n        throw new NoSuchElementException();\n      }\n      try {\n        return reader.next(reuse);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e, \"Failed to read next record\");\n      }\n    }\n\n    @Override\n    public void sync(long position) throws IOException {\n      reader.sync(position);\n    }\n\n    @Override\n    public boolean pastSync(long position) throws IOException {\n      return reader.pastSync(position);\n    }\n\n    @Override\n    public long tell() throws IOException {\n      return reader.tell();\n    }\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroIterable.java#L144-L180","documentation":"AvroRangeIterator.next() advances the underlying Avro reader and deserializes the next record into the reuse instance. An IOException during deserialization or stream read is wrapped in RuntimeIOException with a stable 'Failed to read next record' message, since a partial record cannot be returned.","triggerScenarios":"Calling next() on a range iterator when block decompression fails, the stream ends mid-block, or the record schema cannot decode the bytes (schema/codec mismatch between writer and reader).","commonSituations":"Corrupted object in storage; reader schema incompatible with file schema causing decode errors surfaced as IOExceptions; missing decompression codec; network interruption mid-block.","solutions":["Retry the read with a fresh file handle to rule out transient IO","Verify the compression codec libraries are present (snappy/zstd/bzip2)","Confirm the reader function/schema matches the file's schema (check getMetadata for writer schema)","If corruption is confirmed, restore/rewrite the affected data file"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (CloseableIterator<D> iter = iterable.iterator()) {\n  while (iter.hasNext()) sink(iter.next());\n} catch (RuntimeIOException e) {\n  if (attempts++ < maxRetries) reopenAndSkip(consumedRows);\n  else throw e;\n}","preventionTips":["Ensure the read codec matches the write codec (check file metadata)","Retry transient failures with fresh streams instead of resuming broken ones","Restore/rewrite files flagged as corrupted","Keep reader schemas compatible with writer schemas"],"tags":["avro","io","deserialization"],"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"}