apache/iceberg · warning
An error occurred while aborting the stream
Error message
An error occurred while aborting the stream
What it means
S3InputStream.abortStream() logs this warning when calling Abortable.abort() on the underlying S3 stream (or reading it to check for remaining data) throws. It is a best-effort cleanup path during close(); the original stream is still closed and the abort failure is not propagated.
Source
Thrown at aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java:302
}
// the Apache HTTP client will throw a ConnectionClosedException
// when closing an aborted stream, which is expected
if (!e.getClass().getSimpleName().equals("ConnectionClosedException")) {
throw e;
}
}
stream = null;
}
}
private void abortStream() {
try {
if (stream instanceof Abortable && stream.read() != -1) {
((Abortable) stream).abort();
}
} catch (Exception e) {
LOG.warn("An error occurred while aborting the stream", e);
}
}
public void setSkipSize(int skipSize) {
this.skipSize = skipSize;
}
@SuppressWarnings({"checkstyle:NoFinalizer", "Finalize", "deprecation"})
@Override
protected void finalize() throws Throwable {
super.finalize();
if (!closed) {
close(); // releasing resources is more important than printing the warning
String trace = Joiner.on("\n\t").join(Arrays.copyOfRange(createStack, 1, createStack.length));
LOG.warn("Unclosed input stream created by:\n\t{}", trace);
}
}
}View on GitHub (pinned to 86d9c8fc54)
Solutions
- Ensure the AWS S3 client / FileIO outlives all streams derived from it; close streams before closing the client.
- Check network connectivity and S3 endpoint health if this appears during normal partial reads.
- Read the full stream when practical, or rely on abort() so incomplete reads are cleaned up; treat this warn as non-fatal.
- Upgrade Iceberg/AWS SDK versions to pick up stream-abort robustness fixes.
Example fix
// before
stream.close(); s3Client.close(); // client closed while streams still aborting
// after
try (S3InputStream in = (S3InputStream) fileIO.newInputFile(file).newStream()) {
// read data
}
// then close the client after all streams are closed
s3Client.close(); Defensive patterns
Strategy: try-catch
Try / catch
try (inputStream) { ... } catch (Exception e) { LOG.debug("stream abort/close issue suppressed", e); } // the abort warning is non-fatal; ensure client outlives streams Prevention
- Close streams before closing the FileIO/AWS client
- Prefer full reads or rely on abort to clean partial reads
- Monitor for repeated warnings indicating network or client-lifecycle problems
When it happens
Trigger: Calling close() on an S3InputStream whose underlying stream still has unread data, and either stream.read() in the abort check throws or the Abortable.abort() call fails (e.g. connection already broken, S3 client shutdown, network reset).
Common situations: Partially reading a large S3 file then closing (random-read/row-group skipping patterns), closing streams during task cancellation or executor shutdown, transient network errors to S3, or the AWS client being closed before the stream.
Related errors
- Failed to create S3 analytics accelerator input stream for:
- An error occurred while closing the stream
- Failed to delete staging file: {}
- Cannot initialize S3FileIOAwsClientFactory, missing no-arg c
- Cannot initialize S3FileIOAwsClientFactory, %s does not impl
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/3a6b8912992eee3b.
Report an issue: GitHub.