Refresh pooled connections before credential expiry - #4216
Conversation
|
Thanks for picking this up, and for posting the design note on #3895 before starting — that's appreciated. Before going further on the implementation, I'd like to settle the underlying need. Two things about the current shape are worth flagging regardless. Separately, we're leaning towards solving this at the pool layer instead: an age/idle sweep over pooled connections that reuses the existing mark_for_reconnect() / should_reconnect() mechanism, so idle and in-use connections are retired consistently across standalone, cluster and sentinel, and the pool can also shrink back after a burst. If you'd like to re-target the PR onto that design I'd be glad to review it. I'll leave this as a draft in the meantime. |
Fixes #3895
Motivation
Connection pools can keep a socket alive beyond the lifetime of the credentials used to authenticate it. This is especially problematic for rotating credentials such as Azure Workload Identity tokens: the pool continues to hand out an established connection, which eventually fails authentication after the token expires.
Solution
max_connection_lifetimeconnection setting;Nonepreserves current behavior.Tests
invoke linters,compileall, andgit diff --checkpassed.The local pool/Sentinel integration suites require services not available in this checkout: the local Redis server has DEBUG disabled and no Sentinel is listening on the configured ports.