Hi all,

I'd like to flag a small bug fix and get a reviewer when someone has a
moment.

JIRA: https://issues.apache.org/jira/browse/KAFKA-21686
PR: https://github.com/apache/kafka/pull/24431

Problem: ExpiringCredentialRefreshingLogin's refresher thread waits the
whole interval until the next re-login with a single
time.sleep(nextRefreshMs - nowMs). Thread.sleep uses a relative,
monotonic-clock timeout that does not advance while the host is suspended
(laptop OS sleep, or a paused / live-migrated VM). If the host is suspended
during that sleep, on resume the token has expired by wall-clock time but
the re-login hasn't fired yet, so the client keeps presenting an expired
token and authentication fails until the original sleep elapses. I ran into
this in a multi-day soak test: after a ~4-hour laptop suspend,
SASL/OAUTHBEARER clients kept failing with invalid_token until the thread's
sleep finally elapsed.

Fix: wait in bounded chunks (60s), re-reading the wall clock after each
chunk, and re-login as soon as the deadline has passed. This caps how late
the re-login can be after a resume to one chunk. No public interface
change; existing tests pass, plus two new unit tests that simulate a
suspend by jumping a MockTime clock mid-sleep.

Two things I'd appreciate input on:
- whether 60s is a reasonable bound, or if this should be configurable;
- whether the client-callback refresh path has the same gap (I scoped this
PR to the login refresh thread only; a failed re-authentication triggering
an early refresh is a separate, larger change I deliberately left out).

Thanks,
Qingjun Wu (JIRA: qjwu)

-- 
Best Regards
             Qingjun W

Reply via email to