Repository navigation
Conversation
ZENOTME
marked this pull request as draft
November 30, 2026 06:30
ZENOTME
force-pushed
the
codex/s3-client-lifecycle
branch
from
November 30, 2026 08:48
8e824cf to
80208c1
Compare
ZENOTME
marked this pull request as ready for review
November 30, 2026 08:51
ZENOTME
force-pushed
the
codex/s3-client-lifecycle
branch
2 times, most recently
from
November 30, 2026 09:00
32bf308 to
1b759c5
Compare
Author
|
cc @JingsongLi |
ZENOTME
force-pushed
the
codex/s3-client-lifecycle
branch
from
November 30, 2026 09:23
1b759c5 to
6a3b0dd
Compare
ZENOTME
force-pushed
the
codex/s3-client-lifecycle
branch
from
November 30, 2026 09:53
6a3b0dd to
2ad88e7
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
…ject-store FileIOs Co-authored-by: Cursor <cursoragent@cursor.com>
ZENOTME
force-pushed
the
codex/s3-client-lifecycle
branch
from
November 30, 2026 10:06
2ad88e7 to
f61a71d
Compare
…o cache map Co-authored-by: Cursor <cursoragent@cursor.com>
Keep closed checks and map publish under the instance monitor, but run FileIO.get/createFileSystem outside so different authorities can initialize in parallel. Close unpublished creations when racing with close. Mark Jindo closed before closing the presigner and always clear both FS maps in finally. Co-authored-by: Cursor <cursoragent@cursor.com>
ZENOTME
marked this pull request as draft
November 30, 2026 11:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: fixes #11532 (related to #8548).
When
RESTTokenFileIOrotates temporary credentials (e.g., S3 STS session tokens), it already manages a boundedFILE_IO_CACHEwithfile-io.allow-cache=falseand closes evictedFileIOinstances. However, underlying object-store clients (such as S3A clients and their AWS SDK timer threadssdk-ScheduledExecutor) still leaked on every token rotation because:S3FileIO(as well asCOSNFileIO,GSFileIO, andAzureFileIO) ignoredfile-io.allow-cache=false, always inserted every credential-bearing configuration into an unbounded staticCACHE, and did not overrideFileIO.close().OBSFileIOreadfile-io.allow-cachebut lackedclose(), whileOSSFileIOandJindoFileIOcould NPE inclose()iffsMaphad not been initialized yet.PluginFileIO(used byS3Loader/S3ALoader/OSSLoader, etc.) andResolvingFileIOdid not overrideFileIO.close(), soRESTTokenFileIO's cache eviction callback never reached the underlying pluginFileIO.FileIO.checkAccess()instantiated and probed aFileIOviaexists(path)onpreferIO/fallbackIO/HadoopFileIOLoaderpaths and then discarded it without closing beforeFileIO.get()created a second instance, leaking an uncached client per load.RESTTokenFileIO.FILE_IO_CACHEused a fixed 10-hourexpireAfterAccessregardless of token expiration, keeping expired short-lived tokens cached for up to 10 hours while prematurely evicting longer-lived tokens (e.g., 24h) after 10 hours.Changes
Concurrent first access to the same filesystem key now shares one initialization per FileIO instance. Different buckets can initialize concurrently, and closing an owner during initialization still cleans up its unpublished private client.
S3FileIO:file-io.allow-cache=falseby bypassing staticS3FileIO.CACHEand managing per-instanceS3AFileSysteminstances infsMap(preserving Apache HTTP pool-shutdown recovery).RecoverableS3AFileSysteminstances removed during pool-shutdown recovery and close both active and retired instances insynchronized close()(null-safe whenfsMap == null).S3FileIO.CACHEbehavior completely unchanged whenfile-io.allow-cache=true.Other object-store
FileIOplugins (OSS,OBS,COSN,GS,Azure,Jindo):file-io.allow-cache=falseinCOSNFileIO,GSFileIO, andAzureFileIOby bypassing their staticCACHE.synchronized close()inOBSFileIO,COSNFileIO,GSFileIO, andAzureFileIO, and add the missingfsMap != nullguard inOSSFileIO.close()andJindoFileIO.close().FileIO,PluginFileIO, &ResolvingFileIO:FileIOinstance inFileIO.get()(probeAccess(...)) and close it on probe failure or missingrequiredOptions.synchronized close()inPluginFileIOandResolvingFileIOforwarding to the underlying delegateFileIO(s) under the plugin/resolving context classloader.RESTTokenFileIO.FILE_IO_CACHE:expireAfterAccesswith a CaffeineExpirybased ontoken.expireAtMillis + 5m_grace(Long.MAX_VALUEtokens do not expire by time and remain bounded bymaximumSize), while preserving the existing immediateIOUtils.closeQuietly(value)eviction listener.Tests
Added concurrent first-access coverage for the resolver, private S3A instances and shared GCS filesystems. With four simultaneous reads against a local S3 endpoint, the SDK sent one bucket probe and its scheduler thread count returned to zero after close. Two concurrent COSN readers and a subsequent FileIO all received the same live filesystem.
FileIOTest: verifiespreferIOreuses the probed instance (1 created, 1 closed) and closes failed probes before falling back.PluginFileIOTest: verifiesclose()forwards to the loaded delegate underpluginClassLoader()and is idempotent.ResolvingFileIOTest: verifiesclose()closes all resolved delegates once.RESTTokenFileIOTest: verifies finite-TTL tokens (including 24h TTL) expire atexpireAtMillis + gracewithout premature 10h eviction,Long.MAX_VALUEtokens do not expire by time, andmaximumSizeevictions close immediately.S3FileIOLifecycleTest: verifiesfile-io.allow-cache=falsebypasses staticS3FileIO.CACHE, closes uncachedS3AFileSysteminstances onclose()(including before first use and retired instances after pool-shutdown recovery), and verifiesfile-io.allow-cache=truekeeps existing shared-cache semantics.Verified checkstyle, spotless, enforcer, and compilation across
paimon-commonand all 7 object-store modules (s3-impl,oss-impl,obs-impl,cosn-impl,gs-impl,azure-impl,jindo), plus targeted unit tests inpaimon-common,paimon-s3-impl,paimon-oss-impl, andpaimon-gs-impl.