GLM-5.3 · 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
2 of 3
Comments published
4
Comments matching a bug
2
Comments not matching
2
Cost of this PR
$1.143

Published comments (4)

highbugpkg/storage/unified/search/bleve.go:85-90

Removing whole-function lock exposes data race and lost errors in searchSupport.init workers — With `cacheMu` gone, the `group.Go` workers race on shared `err` and `totalBatchesIndexed`, tripping CI's `-race` detector and letting a `nil` overwrite a build failure so `init` reports success with missing indexes. Declare a local `err` per closure and make `totalBatchesIndexed` atomic or mutex-protected.

highbugpkg/storage/unified/resource/search.go:215-219

TotalDocs reads bleve cache without lock, racing with index-building goroutine — An unlocked iteration of `b.cache` while the event goroutine's `BuildIndex` writes it is an unrecoverable concurrent map crash. Acquire `cacheMu.RLock()` inside `TotalDocs`, which also covers the lockless prometheus read in bleve_index_metrics.go.

highperformancepkg/storage/unified/resource/server.go:258-262

Blocking Init in NewResourceServer stalls Grafana startup on search-index build — Since `ProvideUnifiedStorageClient` wires this into the main Grafana server, the synchronous `Init` blocks wire-graph and HTTP/metrics readiness behind the full index build, risking probe failures and crash loops. Keep eager init for the standalone storage-server; build asynchronously with a readiness gate when constructed in-process.

mediumbugpkg/server/module_server_test.go:35-38

Postgres skip disables only CI coverage of changed StorageServer startup path — The commit history shows this test now fails under Drone with postgres after these changes, so the skip masks a live regression in the eager `Init` startup instead of fixing it. Resolve the underlying startup or timing failure and remove the skip.

Gold bugs found (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.

Gold bugs missed (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.