MiniMax M3 · Balanced

unified-storage-performance-optimizations-grafana-codex

Grafana · Go · S · 30–99 lines · 5 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 3
Comments published
2
Comments matching a bug
1
Comments not matching
1
Cost of this PR
$0.117

Published comments (2)

highbugpkg/storage/unified/search/bleve.go:96-104

BuildIndex drops lock around index creation causing same-key race — Dropping the function-level `b.cacheMu` lock from `BuildIndex` lets two concurrent callers missing the cache both invoke `bleve.New` and `idx.Flush()` on the same disk directory, risking on-disk corruption. Capture the lock, ideally a per-key lock, around the full construction so only one goroutine builds a given key.

highbugpkg/storage/unified/resource/server.go:255-265

NewResourceServer blocks synchronously on Init including search indexing — `NewResourceServer` now synchronously runs `s.Init(ctx)`, which triggers `s.search.init(ctx)` to build all search indexes from `GetResourceStats` before returning. Run `Init` asynchronously (e.g. `go s.Init(s.ctx)`) so every caller—like `pkg/storage/unified/sql/server.go`—no longer blocks on indexing.

Gold bugs found (1)

mediumBuildIndex now locks only the final cache assignment, so concurrent callers for the same uncached key all build the same expensive index in parallel and the last one overwrites the others.

Gold bugs missed (2)

highThe new startup log calls TotalDocs, which iterates the index cache without a lock, after the event goroutine that can add indexes has started, so a concurrent map read and write can crash the process.
mediumThe PR skips the storage-server module integration test on postgres instead of fixing the failure, removing coverage of the new eager initialization on postgres.