Amazon Ergo 1.0 · Balanced

unified-storage-performance-optimizations-grafana-codex

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

The normal review, with one generalist agent. 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
$0.801

Published comments (2)

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

TotalDocs read races with watcher-driven cache writes — The startup log calls `TotalDocs()` after the write-event watcher starts, so an event-driven insert into `bleveBackend.cache` can trigger a fatal concurrent map iteration and map write panic. Hold `cacheMu.RLock` while reading doc counts, or otherwise synchronize `TotalDocs`.

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

Concurrent same-key builds race on index creation and cache writes — Same-key `BuildIndex` calls can now overwrite `b.cache[key]`, discarding a fully built index, and file-backed builds can hit `bleve.New` open/create errors on the shared path. Use per-key singleflight or locking, or guard the cache write to reuse an existing entry, while preserving cross-key parallelism.

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.