Conversation
…REST tokens RESTTokenFileIO bakes the vended token into the delegate FileIO's options, so a stream that is already open keeps signing with the token it was opened with and fails once that token expires. OSSFileIO now resolves credentials per request through a provider that reads the current token from RESTTokenFileIO via CredentialsSupplierRegistry. OSSLoader also accepts fs.oss.credentials.provider in place of the access keys.
|
Reviewed 93f7fc7. The REST-token/open-stream problem has clear end-to-end value, and the per-request OSS signing path is plausible. I found one production blocker in the supplier lifecycle: [P1] Keep the supplier alive for the lifetime of an open OSS stream. Validation: |
…uses it Evicting a delegate from RESTTokenFileIO's cache unregistered its supplier even though the OSS client and its open streams were still live, so they fell back to their last credentials and failed at the next expiry. The registry now holds suppliers weakly. OSSFileIO and RegisteredCredentialsProvider keep a strong reference once they resolve one, so a supplier lives exactly as long as a client or stream that can still sign with it.
Passing a live supplier from RESTTokenFileIO to the OSS client through a static registry tied the supplier to objects the client does not own, and got the lifetime wrong on cache eviction. Like Iceberg's VendedCredentialsProvider and Hadoop's credential providers, the OSS provider is now built from configuration alone: RESTTokenFileIO names the table and the token expiry in the delegate options, OSSFileIO hands the catalog options to RESTTokenCredentialsProvider, and the provider loads the table's token through RESTTokenRefresher when it is about to expire. The registry is removed.
… clock The test waited on the wall clock for the first token to enter the refresh window, so on a slow CI runner the refresh happened before the first read. It now moves the refreshers' clock forward instead.
RESTTokenRefresher held its lock across the catalog request, whose client may retry for minutes, so every OSS request on the client waited while the current token was still valid. Now one caller reloads and the others keep the valid token; with an expired token, callers fail fast within the retry interval. A reloaded token is layered over the catalog options as RESTTokenFileIO does, OSSFileIO reads only a constant from RESTTokenRefresher so an older paimon-common still loads it, and OSSLoader names its option keys.
|
Thanks, good catch. Instead of fixing the supplier's lifetime I removed the registry: The evicted OSS FileSystem not being closed predates this PR: |
RESTTokenFileIO cached delegates by token alone. Now that a delegate reloads the token as a specific table and catalog user, another table or user holding the same token reused it and reloaded as the wrong one. The cache key now also covers the token's table and the catalog options. RESTTokenRefresher reloaded whenever less than an hour was left, so a token that lives shorter was reloaded on every OSS request. Each token now carries its own reload time: an hour before expiry, or halfway through when it lives shorter, and at least ten seconds after it arrived. An expired token is never returned.
Purpose
With a REST catalog that vends data tokens,
RESTTokenFileIObuilds the OSSFileIOwith the token it holds at that moment. A refresh only reaches FileIOs created afterwards, so a stream that is already open, such as a long read or a multipart upload, keeps signing with the old token and fails once it expires.OSSFileIOnow signs each request throughRESTTokenCredentialsProvider, which reloads the table's data token from the catalog before it expires, as Iceberg'sVendedCredentialsProviderdoes for S3. A token is reloaded an hour before it expires, or halfway through when it lives shorter; while it is still valid, one caller reloads it and the others keep using it, and a failed reload is retried after 10 seconds. Since a delegate now reloads the token as a table and a catalog user, it is shared only by callers with the same ones.fs.oss.credentials.providercan now also replace the access keys.Tests
RESTTokenRefresherTest: 6 new cases.RESTTokenCredentialsProviderTest: 3 new cases.RESTTokenFileIOOnOSSTest: 2 new cases.RESTTokenFileIOTest: 2 new cases, 12 tests passed.OSSLoaderTest: 1 new case.