{"record":{"id":"b65f523330e30e9f","repo":"apache/iceberg","slug":"retrying-read-from-s3-reopening-stream-attempt","errorCode":null,"errorMessage":"Retrying read from S3, reopening stream (attempt {})","messagePattern":"Retrying read from S3, reopening stream \\(attempt (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java","lineNumber":77,"sourceCode":"  private final S3Client s3;\n  private final S3URI location;\n  private final S3FileIOProperties s3FileIOProperties;\n\n  private InputStream stream;\n  private long pos = 0;\n  private long next = 0;\n  private boolean closed = false;\n\n  private final Counter readBytes;\n  private final Counter readOperations;\n\n  private int skipSize = 1024 * 1024;\n  private RetryPolicy<Object> retryPolicy =\n      RetryPolicy.builder()\n          .handle(RETRYABLE_EXCEPTIONS)\n          .onRetry(\n              e -> {\n                LOG.warn(\n                    \"Retrying read from S3, reopening stream (attempt {})\", e.getAttemptCount());\n                resetForRetry();\n              })\n          .onFailure(\n              e ->\n                  LOG.error(\n                      \"Failed to read from S3 input stream after exhausting all retries\",\n                      e.getException()))\n          .withMaxRetries(3)\n          .build();\n\n  S3InputStream(S3Client s3, S3URI location) {\n    this(s3, location, new S3FileIOProperties(), MetricsContext.nullMetrics());\n  }\n\n  S3InputStream(\n      S3Client s3, S3URI location, S3FileIOProperties s3FileIOProperties, MetricsContext metrics) {\n    this.s3 = s3;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java#L59-L95","documentation":"S3InputStream registers a failover RetryPolicy for the AWS CRT/S3 client: when a read fails with a retryable exception, it logs this warning including the attempt count, resets and reopens the stream from the last known position, and retries. It indicates an S3 read was interrupted but transparently recovered; only onFailure (an error log) means the read truly failed.","triggerScenarios":"Reading a file via S3FileIO.newInputFile().newStream() when the connection is dropped mid-read, S3 returns 5xx/timeout, or the CRT client hits transient network errors.","commonSituations":"Long-running scans over flaky networks; S3 throttling; large sequential reads interrupted by connection reset; short read timeouts.","solutions":["No action needed for occasional retries — the stream self-heals","If retries are frequent, investigate network stability or S3 endpoint/proxy settings","Increase client read timeouts or reduce concurrency causing throttling","Inspect the onFailure ERROR log for the terminal failure if reads actually break"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight S3 reachability before large reads\ns3Client.headObject(b -> b.bucket(bucket).key(key));","typeGuard":null,"tryCatchPattern":"try (InputStream in = inputFile.newStream()) { readAll(in); } // transient retries are automatic; IOException here means retries were exhausted","preventionTips":["Harden network paths (VP endpoints, keep-alives) for large sequential reads","Tune CRT client timeouts if retries are frequent","Monitor the attempt counter trend; growth indicates persistent network issues"],"tags":["aws","s3","retry","network"],"backgroundTag":"request-timeout","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"}