Repository navigation
Benchmark: grafana PR 90939 - #18
celmis-codereviewer wants to merge 1 commit into
Conversation
celmis-codereviewer
left a comment
There was a problem hiding this comment.
💬 COMMENT — findings to consider
Full findings and scope are in the review summary comment on this pull request — one persistent comment, updated in place on every run.
celmis-codereviewer
left a comment
There was a problem hiding this comment.
💬 COMMENT — findings to consider
Full findings and scope are in the review summary comment on this pull request — one persistent comment, updated in place on every run.
| if cfg.Env != setting.Dev && ret != nil { | ||
| return ret, nil | ||
| } | ||
| entryPointAssetsCacheMu.Lock() |
There was a problem hiding this comment.
Why: When concurrent requests call GetWebAssets while entryPointAssetsCache is nil, a goroutine waiting at entryPointAssetsCacheMu.Lock() on line 48 proceeds to re-execute asset loading after acquiring the lock because ret checked on line 45 was evaluated prior to acquiring the write lock and entryPointAssetsCache is not re-checked after being populated by the first goroutine.
🟠 Missing cache re-check after acquiring write lock in double-checked locking pattern
In GetWebAssets, when entryPointAssetsCache is nil, multiple goroutines will fail the initial check at line 45 because ret is nil. The first goroutine acquires entryPointAssetsCacheMu.Lock() at line 48 and populates the cache. However, when subsequent goroutines waiting at line 48 acquire the write lock, they do not inspect entryPointAssetsCache again inside the lock. As a result, they bypass the cache and re-compute assets unnecessarily.
| entryPointAssetsCacheMu.Lock() | |
| entryPointAssetsCacheMu.Lock() | |
| defer entryPointAssetsCacheMu.Unlock() | |
| if cfg.Env != setting.Dev && entryPointAssetsCache != nil { | |
| return entryPointAssetsCache, nil | |
| } |
agent: defect · rule: defect.missing-check · confidence: 0.95
🤖 Code Review for PR #18💬 COMMENT — findings to consider Findings
Scope
Performance
Powered by Code Analyzer · context: tree-sitter graph + structural, cve, contract, security, defect |
Benchmark reproduction of grafana#90939