Amazon Ergo 1.0 · Heavy

unified-storage-performance-optimizations-grafana-codex

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

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

Published comments (2)

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

TotalDocs races with watch goroutine writing the bleve cache — A fatal concurrent map iteration and write can crash the process, and `total_docs` can be wrong: `TotalDocs()` reads `b.cache` without `cacheMu` while `BuildIndex` writes it. Log before starting `WatchWriteEvents`, or make `TotalDocs()` hold `b.cacheMu.RLock()`; see `pkg/storage/unified/search/bleve.go`.

mediumbugpkg/storage/unified/search/bleve.go:88-90

BuildIndex no longer serializes concurrent builds for the same key — Concurrent `Search` cache misses for one `NamespacedResource` can make file-backed `bleve.New` calls fail with `index-path-exists` errors, race as writers, or overwrite or leak memory indexes because `BuildIndex` holds `b.cacheMu` only for the final write. Restore per-key serialization around the whole build, or add single-flight in the `Search` caller. **Also found in:** - `pkg/storage/unified/search/bleve.go:137-139`

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.