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