You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "waterWang (via GitHub)" <gi...@apache.org> on 2026/08/22 03:42:02 UTC

[PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

waterWang opened a new pull request, #17768:
URL: https://github.com/apache/iceberg/pull/17768

   Fixes #17756
   
   ## Problem
   
   One failed background OAuth2 token refresh permanently stops refresh for that `AuthSession`.
   
   `scheduleTokenRefresh` chains one-shot scheduled tasks: a successful `AuthSession.refresh(client)` returns the next expiration, which schedules the following task. When refresh fails (retries exhausted + credential fallback fails), `refresh` returns `null`, and the chain simply ends — no manager or request path re-arms it:
   
   - `authenticate` keeps attaching the stale token already stored in the session.
   - After the token expires, requests receive 401s for the remaining lifetime of the catalog object even after the token endpoint recovers.
   
   Reproduced by the issue: a token endpoint down for ~8s at refresh time (6 `Tasks` attempts + 1 credential fallback, ~3.1s of sleep) permanently disabled refresh. StarRocks reports the same production failure (StarRocks/starrocks#76438).
   
   ## Fix
   
   Distinguish the three outcomes the scheduling chain needs:
   
   1. **Refresh succeeded** → schedule from the new expiration (unchanged).
   2. **Refresh failed temporarily** → schedule a bounded retry (60s) so a transient endpoint outage delays refresh instead of permanently disabling it.
   3. **Session closed** (`stopRefreshing()`/`close()`, i.e. `keepRefreshed == false`) → do not schedule again.
   
   - `scheduleTokenRefresh`: when `refresh()` returns `null` but `session.config().keepRefreshed()` is still `true`, reschedule with a fixed 60s bounded wait instead of dropping the chain.
   - `fromAccessToken` initial-refresh path: when the initial refresh of an already-expired token fails while the session stays active, schedule the same bounded retry instead of leaving `expiresAtMillis` null (which skipped scheduling entirely).
   
   A fixed bounded retry avoids hammering an unavailable token endpoint while still allowing recovery, and it automatically stops for closed sessions (no unconditional `null`-rescheduling loop).
   
   ## Tests
   
   Three new tests in `TestOAuth2Util`:
   
   - `failedRefreshSchedulesBoundedRetryWhileSessionStaysActive` — a scheduled refresh that fails (token endpoint down) reschedules with a ~60s delay.
   - `closedSessionDoesNotRescheduleAfterFailedRefresh` — after `close()`, a failed refresh does not reschedule.
   - `initialRefreshFailureSchedulesBoundedRetryWhenSessionStaysActive` — an already-expired token whose initial refresh fails still schedules the bounded retry.
   
   All 12 tests in `TestOAuth2Util` pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

Posted by "Gerrrr (via GitHub) via issues" <is...@iceberg.apache.org>.
Gerrrr commented on PR #17768:
URL: https://github.com/apache/iceberg/pull/17768#issuecomment-6756138494

   Hey @uros-b @waterWang! We're hitting #17756 in production as well. Since this PR has been inactive for a while, I'd like to pick it up as suggested above, with co-author credit to @waterWang. Happy to hand it back if you'd rather continue.
   
   My understanding is that the following things need to be changed for this PR to get merged:
   1. Fix the spotless check.
   2. Replace `core:` with `Core:` in the PR title.
   3. Only retry on an actual retry failure.
   4. Use exponential backoff from 1s to 60s instrad of a fixed 60s.
   
   Does this match your expectations?
   
   Question: Should permanent failures like 401/400 from the token endpoint stop the retries? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

Posted by "whitepowder (via GitHub)" <gi...@apache.org>.
whitepowder commented on PR #17768:
URL: https://github.com/apache/iceberg/pull/17768#issuecomment-5946893460

   Hi @uros-b, since you were involved in the recent OAuth session discussion in #18251, could you please take a look at this PR when you have a chance?
   
   We are experiencing the issue described in #17756 in production with the Iceberg Kafka Connect sink: after an OAuth2 token refresh failure, the session does not recover and eventually starts receiving 401 responses until the Connect pod is restarted.
   
   This PR seems to address exactly this failure mode, but it was automatically closed due to inactivity before being reviewed.
   
   Would it make sense to reopen and review it?
   
   Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #17768: core: retry REST OAuth2 token refresh after transient failure
URL: https://github.com/apache/iceberg/pull/17768


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17768:
URL: https://github.com/apache/iceberg/pull/17768#issuecomment-5881289253

   This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] core: retry REST OAuth2 token refresh after transient failure [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17768:
URL: https://github.com/apache/iceberg/pull/17768#issuecomment-5769503751

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org