DeepSeek V4 Pro · Balanced
dual-storage-architecture-grafana-codex
Grafana · Go · L · 300–799 lines · 4 files
The normal review, with one generalist agent. Judge: Claude Opus 5.5.
- Gold bugs found
- 6 of 11
- Comments published
- 7
- Comments matching a bug
- 6
- Comments not matching
- 1
- Cost of this PR
- $0.495
Published comments (7)
Legacy update uses raw objInfo instead of storage result, diverging writes — The legacy store re-runs objInfo.UpdatedObject against its own possibly stale or absent old object, so the legacy write diverges from unified storage with a different resourceVersion/UID or a create instead of an update. Wrap the storage result with `updateWrapper{upstream: objInfo, updated: res}` so both stores persist the same object.
Async legacy write uses request-scoped context canceled after handler returns — The apiserver cancels the request-scoped ctx as soon as the handler returns, so the goroutine observes `context.Canceled` and the legacy backup is silently dropped. Derive the goroutine context from `context.WithoutCancel(ctx)` so the timeout-only context survives request completion; the same applies in `Delete`, `Update`, and `DeleteCollection`.
Create error path records legacy duration metric — Recording the storage failure in the legacy histogram pollutes `dual_writer_legacy_duration_seconds` and also uses the wrong `startStorage` timestamp. Use `recordStorageDuration` here, and make the same correction in `Update`.
DeleteCollection records legacy duration in storage histogram — `startLegacy` belongs to the legacy histogram, so this call miscounts it as a storage operation. Use `recordLegacyDuration` so delete-collection timing lands in `dual_writer_legacy_duration_seconds`.
Delete records storage duration metric with object name as kind label — Using `name` as the `kind` label creates an unbounded number of Prometheus series, one per object name. Pass `options.Kind` so metric cardinality stays bounded.
Delete returns early on Storage NotFound and leaves stale legacy copies — Skipping `d.Legacy.Delete` on NotFound leaves stale legacy copies that can resurface if reads fall back to legacy storage. Only short-circuit non-NotFound errors so legacy cleanup still runs when storage reports NotFound.
Delete sets context logger to d.Log instead of log — Passing the bare `d.Log` loses the name/kind/method fields for `klog.FromContext` calls inside `d.Storage.Delete`. Pass the just-built `log` to `klog.NewContext` like every other mode-3 method.