Skip to content

[filesystem][s3] Recover S3A filesystem after connection pool shutdown - #11037

Open
PyRSA wants to merge 4 commits into
apache:masterfrom
PyRSA:fix/s3a-connection-pool-recovery
Open

PyRSA wants to merge 4 commits into
apache:masterfrom
PyRSA:fix/s3a-connection-pool-recovery

Conversation

@PyRSA

@PyRSA PyRSA commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fixes #10711

S3FileIO may continue reusing a cached S3AFileSystem after its underlying Apache HTTP connection pool has been shut down, causing subsequent S3 operations to fail with IllegalStateException: Connection pool shut down.

Changes

  • Detect Connection pool shut down failures through an AWS SDK execution interceptor and mark the affected S3A filesystem as unusable.
  • Evict the unusable filesystem from the shared cache using identity-based removal to avoid removing a replacement instance.
  • Recreate the filesystem on subsequent access, allowing other S3FileIO instances with the same cache key to recover as well.
  • Handle filesystem initialization and cache publication failures safely, preventing unusable instances from being published or retained.
  • Add regression tests covering cache eviction and replacement, concurrent access, initialization failures, and unrelated exceptions.

Scope

  • Applies to the Hadoop S3A client using the Apache HTTP transport.
  • Does not automatically retry failed S3 operations.
  • Does not cover the Netty async client.

* failed requests are not retried automatically; callers must retry and obtain a recovered
* filesystem through {@link S3FileIO}.
*/
class RecoverableS3AFileSystem extends S3AFileSystem {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing scheme test rejects the new subclass:
Introducing this subclass changes the runtime class name, but paimon-filesystems/paimon-s3/src/test/java/org/apache/paimon/s3/S3ASchemeTest.java:145 assertEquals("org.apache.hadoop.fs.s3a.S3AFileSystem", fs.getClass().getName()); still requires the exact name org.apache.hadoop.fs.s3a.S3AFileSystem. Both parameterized scheme cases consequently fail in the required JDK 8 and JDK 11 CI jobs. Please update that test to verify S3A ancestry/behavior without requiring the old concrete class name; note that this plugin test may use a separate classloader, so a simple cross-classloader instanceof may not be reliable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I've updated S3ASchemeTest to verify the S3A superclass hierarchy by class name instead of asserting the exact runtime class name. This avoids relying on instanceof, which may be unreliable across isolated classloaders.

@PyRSA
PyRSA requested a review from Akash3121 November 10, 2026 04:57

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified actual recovery on Hadoop 3.4.2 / AWS SDK 2.29.52 against a loopback endpoint. I closed the Apache transport, observed the first HEAD fail, then verified both S3FileIO instances converged on a replacement and the peer HEAD succeeded. All 12 cache tests passed. The inline comments cover two additional publication and retention reproductions.

@PyRSA
PyRSA force-pushed the fix/s3a-connection-pool-recovery branch from d9c7823 to b519d14 Compare November 10, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] S3FileIO keeps reusing a cached S3A client after its HTTP connection pool shuts down

3 participants