{"record":{"id":"01ceef4ea362a186","repo":"apache/iceberg","slug":"failed-to-read-stream-while-finding-starting-row-p","errorCode":null,"errorMessage":"Failed to read stream while finding starting row position","messagePattern":"Failed to read stream while finding starting row position","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroIO.java","lineNumber":198,"sourceCode":"          if (!Arrays.equals(fileSync, blockSync)) {\n            throw new RuntimeIOException(\"Invalid sync at %s\", nextSyncPos);\n          }\n        }\n\n        long rowCount = decoder.readLong();\n        long compressedBlockSize = decoder.readLong();\n\n        totalRows += rowCount;\n        nextSyncPos = in.getPos() + compressedBlockSize;\n      }\n\n      return totalRows;\n\n    } catch (EOFException e) {\n      return totalRows;\n\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to read stream while finding starting row position\");\n    }\n  }\n}\n","sourceCodeStart":180,"sourceCodeEnd":202,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroIO.java#L180-L202","documentation":"While scanning Avro blocks to locate the row position corresponding to a start offset, findStartingRowPos reads block metadata and rows from the stream. Any IOException other than EOF aborts the position search, and the method rethrows it as RuntimeIOException so callers fail fast instead of silently returning a wrong row offset.","triggerScenarios":"Reading block metadata (rowCount, compressedBlockSize) or skipping rows in an Avro data file when the underlying stream raises a non-EOF IOException: network reset while reading from object storage, truncated file, closed stream, or local disk read failure.","commonSituations":"Transient S3/HDFS read errors during large scans; file truncated mid-upload; task retried after the local block cache was evicted; NFS/positioned reads failing on Hadoop FileIO mid-task.","solutions":["Retry the scan/task — transient network IO failures usually resolve on retry with a fresh file handle","Verify the file is complete (compare with the manifest's recorded file size and checksum where available)","Re-open the file with a fresh InputFile instead of reusing the failed stream","If the file is genuinely truncated, rewrite the data file from a source of truth and repair the table"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check readability and size before scanning\nif (!fileIO.exists(location)) throw new IllegalStateException(\"Missing file: \" + location);\nif (inputFile.getLength() != manifestEntryFileSize) throw new IllegalStateException(\"Truncated file: \" + location);","typeGuard":null,"tryCatchPattern":"try {\n  return Avro.write(...) /* or read position */;\n} catch (RuntimeIOException e) {\n  if (isTransient(e)) return Retry.withBackoff(3).run(() -> findStartingRowPos(...));\n  throw e;\n}","preventionTips":["Configure object-store client retries and longer read timeouts for large files","Verify completed uploads (size/checksum) before committing manifests","Avoid reading over flaky networks without retry middleware","Keep file sizes moderate to reduce the window for mid-scan IO failures"],"tags":["avro","io","network","read-failure"],"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"}