fix(iam): keep cached authorization available during lazy loads

Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-11-07 02:05:58 +08:00
parent c78ef6a6f6
commit 00270e9f61
2 changed files with 73 additions and 1 deletions
+7 -1
View File
@@ -1743,7 +1743,13 @@ func (store *IAMStoreSys) MergePolicies(policyName string) (string, policy.Polic
p, found := cache.iamPolicyDocsMap[name]
if !found {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
err := store.loadPolicyDoc(ctx, name, loaded)
err := func() error {
// Retain writeMu to serialize cache revisions, but let cached
// authorization readers proceed while storage is unavailable.
store.IAMStorageAPI.unlock()
defer store.IAMStorageAPI.lock()
return store.loadPolicyDoc(ctx, name, loaded)
}()
cancel()
if errors.Is(err, errNoSuchPolicy) {
continue