Claude Sonnet 5.5 · 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
2
Comments matching a bug
2
Comments not matching
0
Cost of this PR
$0.498

Published comments (2)

highbugpkg/storage/unified/resource/search.go:216

Unlocked TotalDocs cache iteration races with event goroutine's index creation — Iterating `bleveBackend.cache` without `cacheMu` can race with `BuildIndex` writes from the event goroutine, causing a fatal concurrent map iteration and write at startup. Take `cacheMu.RLock()` inside `bleveBackend.TotalDocs()`.

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

Concurrent BuildIndex calls for the same key race on index creation — Without the `cacheMu` lock, concurrent `BuildIndex` calls for one key can make the second `bleve.New(dir)` fail on file-backed indexes, or overwrite and leak an in-memory index. Serialize builds per key (a per-key mutex or singleflight) and re-check the cache after acquiring it.

Gold bugs found (2)

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.
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.

Gold bugs missed (1)

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.