GLM-5.3 · 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 Haiku 5.5.

Gold bugs found
3 of 3
Comments published
4
Comments matching a bug
3
Comments not matching
1
Cost of this PR
$1.697

Published comments (4)

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

TotalDocs reads cache map without lock; concurrent BuildIndex crashes process — If any goroutine is in `BuildIndex` while this log line runs, `bleveBackend.TotalDocs` reads `b.cache` without `b.cacheMu` and the runtime fatally crashes the process. Have `TotalDocs` in `search/bleve.go` take `b.cacheMu.RLock()` before iterating.

highbugpkg/storage/unified/search/bleve.go:137-139

Unsynchronized concurrent same-key index builds can duplicate work and corrupt file-backed indexes — Removing the function-wide lock leaves `getOrCreateIndex` unsynchronized, so concurrent same-key builders each scan and the loser's cached index silently drops documents; file-backed builds can corrupt the on-disk index. Add per-key sync — `singleflight` in `getOrCreateIndex`, or a cache re-check under the write lock in `BuildIndex`. **Also found in:** - `pkg/storage/unified/resource/search.go:307-307` - `pkg/storage/unified/search/bleve.go:85-90`

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

NewResourceServer now blocks on full Init and hard-fails, breaking the constructor contract — Every caller now blocks construction on the full index build and hard-fails on any init error — one consumer already broke and was skipped rather than adapted. Revert `NewResourceServer` to returning immediately, leaving init to the separate `Init` path.

mediumbugpkg/server/module_server_test.go:35-38

Postgres skip silences failing integration test instead of fixing it — This skip hides a real postgres failure exactly when this PR rewrites the init path it tests, so regressions go undetected. Fix the cause — `addStorageServerToConfig` hardcodes grafanatest credentials instead of parsing the connection string — or scope the skip to Drone.

Gold bugs found (3)

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.
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 (0)

None.