fix(secret): refresh stale lru cache item in background#12614
Merged
Conversation
Signed-off-by: Nic <[email protected]>
Signed-off-by: Nic <[email protected]>
Signed-off-by: Nic <[email protected]>
nic-6443
marked this pull request as ready for review
September 15, 2025 03:10
nic-6443
requested review from
AlinsRan,
Revolyssup,
bzp2010,
membphis and
nic-chen
September 15, 2025 03:11
membphis
approved these changes
Sep 15, 2025
nic-chen
approved these changes
Sep 16, 2025
Revolyssup
approved these changes
Sep 16, 2025
jizhuozhi
pushed a commit
to jizhuozhi/apisix
that referenced
this pull request
Oct 18, 2025
shreemaan-abhishek
pushed a commit
to shreemaan-abhishek/apisix
that referenced
this pull request
Jan 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Our secret feature includes an LRU cache to store values obtained from the secret provider (vault, AWS, GCP) to reduce the number of requests to the secret provider. However, due to without
invalid_staleparameter, this cache never expires.apisix/apisix/ssl/router/radixtree_sni.lua
Lines 241 to 242 in 9ae2403
apisix/apisix/secret.lua
Lines 188 to 190 in 9ae2403
apisix/apisix/core/lrucache.lua
Lines 54 to 62 in 9ae2403
However, if only the
invalid_staleparameter is specified, when the cache entry expires, it will be necessary to query the secret provider to obtain the secret while receiving downstream requests. This can result in some high-latency long-tail requests.To address this, an
refresh_staleoption is provided in the LRU cache to asynchronously refresh expired items within a timer, reducing the impact on downstream requests.Which issue(s) this PR fixes:
Fixes #
Checklist