-
Notifications
You must be signed in to change notification settings - Fork 332
Closed
Description
Background: #301
The token fetched from the token server may have a TTL, see TokenResponse::expires_in
. In most implementations, the value is about several hours. Our catalog client is a long-lived object, which means that we should handle the token expiration event.
There are two ways:
- Spawn a background task, and setup a ticker with a specified time interval, e.g.
expires_in * 0.9
seconds, and refetch the token when triggered.
- Pros: Easy to implement
- Cons: Must trust the local timer skew
- Cons: Must introduce a timer, which means depending on a specified async runtime
- Call every methods with a retry wrapper. When meeting an unauthorized error, refetch the token and retry the method.
- Pros: Consistent with iceberg-python
- Pros: Does not rely on local clock and specific runtime
- Cons: When expired, thousands of concurrent requests may fail, and then all of them will trigger a token refetch, which is not ideal.
- This can be workaround by some concurrency control, to force only one request will refetch the token and others must wait for the result, but it introduced complexity.
Metadata
Metadata
Assignees
Labels
No labels