apache/iceberg · warning
Failed to close S3SeekableInputStreamFactory
Error message
Failed to close S3SeekableInputStreamFactory
What it means
A warning from AnalyticsAcceleratorUtil's static STREAM_FACTORY_CACHE cleanup: closing the cached S3SeekableInputStreamFactory threw an IOException. The factory (used by the S3 Analytics Accelerator for seekable reads) could not release its resources cleanly; the warning is logged and close proceeds silently otherwise.
Source
Thrown at aws/src/main/java/org/apache/iceberg/aws/s3/AnalyticsAcceleratorUtil.java:91
private static S3SeekableInputStreamFactory createNewFactory(
Pair<S3AsyncClient, S3FileIOProperties> cacheKey) {
ConnectorConfiguration connectorConfiguration =
new ConnectorConfiguration(cacheKey.second().s3AnalyticsacceleratorProperties());
S3SeekableInputStreamConfiguration streamConfiguration =
S3SeekableInputStreamConfiguration.fromConfiguration(connectorConfiguration);
ObjectClientConfiguration objectClientConfiguration =
ObjectClientConfiguration.fromConfiguration(connectorConfiguration);
ObjectClient objectClient = new S3SdkObjectClient(cacheKey.first(), objectClientConfiguration);
return new S3SeekableInputStreamFactory(objectClient, streamConfiguration);
}
private static void close(S3SeekableInputStreamFactory factory) {
if (factory != null) {
try {
factory.close();
} catch (IOException e) {
LOG.warn("Failed to close S3SeekableInputStreamFactory", e);
}
}
}
public static void cleanupCache(
S3AsyncClient asyncClient, S3FileIOProperties s3FileIOProperties) {
STREAM_FACTORY_CACHE.invalidate(Pair.of(asyncClient, s3FileIOProperties));
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Check the logged IOException cause; if it's the async client shutdown, ensure the S3AsyncClient passed to cleanupCache outlives the factory
- Call AnalyticsAcceleratorUtil.cleanupCache explicitly during application shutdown to close factories in a controlled state
- Avoid reusing a factory after its close attempt; re-acquire via the cache
- If repeated, disable the analytics-accelerator feature via S3FileIOProperties if you don't need it
Example fix
// before S3AsyncClient client = S3AsyncClient.create(); client.close(); // closed before factory cleanup -> factory.close() throws AnalyticsAcceleratorUtil.cleanupCache(client, props); // after S3AsyncClient client = S3AsyncClient.create(); AnalyticsAcceleratorUtil.cleanupCache(client, props); // close factory first client.close();
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the client passed to cleanupCache is still open
if (!asyncClientIsShutdown) {
AnalyticsAcceleratorUtil.cleanupCache(asyncClient, s3FileIOProperties);
} Type guard
boolean factoryClosable = factory != null; // mirror the util's null guard
Prevention
- Close the stream factory cache before shutting down the S3AsyncClient
- Call cleanupCache during orderly application shutdown
- Don't share one S3AsyncClient's lifecycle across multiple FileIO instances with different properties
- Read the logged IOException cause to identify which resource failed to close
When it happens
Trigger: Cleanup cache eviction (STREAM_FACTORY_CACHE removal callback) or explicit cleanupCache() invoking factory.close() while the factory's underlying resources (clients, buffers) are in a bad state, e.g. already partially closed or its async client failing shutdown.
Common situations: JVM shutdown with the cache still holding factories; swapping S3FileIOProperties (region/endpoint changes) causing cache eviction; closing a factory whose underlying S3AsyncClient was already shut down by user code.
Related errors
- Failed to create S3 analytics accelerator input stream for:
- Cannot initialize S3FileIOAwsClientFactory, missing no-arg c
- Cannot initialize S3FileIOAwsClientFactory, %s does not impl
- Interrupted when waiting for deletions to complete
- Input malformed or exceeded maximum multipart upload size 5G
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/91238c2d877c8b9d.
Report an issue: GitHub.