Benchmark: grafana PR 97529 - #20
celmis-codereviewer wants to merge 17 commits into
Conversation
…n by passing span ctx. Update some logging.
… up. Locking the whole function was slowing things down.
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.
❌ CHANGES REQUESTED — blocking findings
Full findings and scope are in the review summary comment on this pull request — one persistent comment, updated in place on every run.
| } | ||
| } | ||
|
|
||
| err := s.Init(ctx) |
There was a problem hiding this comment.
Why: ctx is not declared as a parameter or variable in NewResourceServer on line 255; calling s.Init(ctx) on line 258 results in a compile-time error undefined: ctx.
🔴 Undeclared variable ctx passed to s.Init
NewResourceServer accepts opts ResourceServerOptions as its parameter and does not declare or receive a ctx context.Context variable. Invoking s.Init(ctx) on line 258 fails compilation with undefined: ctx.
| err := s.Init(ctx) | |
| err := s.Init(context.Background()) |
agent: defect · rule: defect.undefined-variable · confidence: 0.95
| @@ -99,9 +96,9 @@ func (b *bleveBackend) BuildIndex(ctx context.Context, | |||
| if size > b.opts.FileThreshold { | |||
| dir := filepath.Join(b.opts.Root, key.Namespace, fmt.Sprintf("%s.%s", key.Resource, key.Group)) | |||
| index, err = bleve.New(dir, mapper) | |||
There was a problem hiding this comment.
Why: When concurrent calls to BuildIndex occur for the same key after removing the b.cacheMu lock, both calls execute bleve.New on line 98 using the same directory path, leading to concurrent file access errors or index corruption.
🟠 Unsynchronized file-backed Bleve index creation leads to race conditions
Removing b.cacheMu.Lock() from the beginning of BuildIndex allows concurrent operations for the same resource key to execute bleve.New(dir, mapper) simultaneously on the same filesystem directory path (dir). Creating or opening a Bleve index concurrently on identical directory paths causes file locking conflicts and database corruption.
agent: defect · rule: defect.race-condition · confidence: 0.90
🤖 Code Review for PR #20❌ CHANGES REQUESTED — blocking findings Findings
Scope
Performance
Powered by Code Analyzer · context: tree-sitter graph + structural, cve, contract, security, defect |
Benchmark reproduction of grafana#97529