{"record":{"id":"48dbecb357dd84a2","repo":"apache/iceberg","slug":"failed-to-check-range-end-d","errorCode":null,"errorMessage":"Failed to check range end: %d","messagePattern":"Failed to check range end: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroIterable.java","lineNumber":142,"sourceCode":"\n      try {\n        reader.sync(start);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e, \"Failed to find sync past position %d\", start);\n      }\n    }\n\n    @Override\n    public Schema getSchema() {\n      return reader.getSchema();\n    }\n\n    @Override\n    public boolean hasNext() {\n      try {\n        return reader.hasNext() && !reader.pastSync(end);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e, \"Failed to check range end: %d\", end);\n      }\n    }\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);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroIterable.java#L124-L160","documentation":"AvroRangeIterator.hasNext() checks both that the underlying Avro reader has more records and that it has not passed the configured end offset via reader.pastSync(end). An IOException from either call is wrapped in RuntimeIOException reporting the range end, since the iterator cannot determine whether the range is complete.","triggerScenarios":"Iterating a byte-range AvroIterable when the underlying stream fails during hasNext()/pastSync: object store connection reset, truncated block stream, or a file modified while being read so pastSync cannot be evaluated.","commonSituations":"Long-running Spark/Flink tasks reading large Avro files whose network connections time out; preemption of the underlying stream; file overwritten concurrently by compaction while the range iterator is open.","solutions":["Retry the task; transient IO failures during iteration are typically resolved with a fresh read","Re-open the data file with a fresh AvroIterable and skip already-consumed records","Ensure the file is not concurrently rewritten (isolate compaction from reads via snapshot isolation)","Check storage/network stability (timeouts, proxies) for large files"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure range end does not exceed the file length\nPreconditions.checkArgument(end <= inputFile.getLength(), \"Range end %s exceeds file length\", end);","typeGuard":null,"tryCatchPattern":"try (CloseableIterator<D> iter = iterable.iterator()) {\n  while (iter.hasNext()) consume(iter.next());\n} catch (RuntimeIOException e) {\n  retryWithFreshHandle(remaining -> ...);\n}","preventionTips":["Set robust object-store timeouts/retries for long scans","Avoid modifying/compacting files while tasks read them","Checkpoint progress so tasks can resume from a known offset after failure","Monitor network stability in clusters reading large remote files"],"tags":["avro","io","iteration","network"],"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"}