Claude Sonnet 5.5 · Balanced

dual-storage-architecture-grafana-codex

Grafana · Go · L · 300–799 lines · 4 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
4 of 9
Comments published
4
Comments matching a bug
4
Comments not matching
0
Cost of this PR
$0.548

Published comments (4)

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:50-57

Async legacy create write uses request context that is cancelled on return — The request `ctx` is cancelled once the handler returns, so the background write can abort mid-flight and leave the legacy store out of sync. Derive the timeout from `context.WithoutCancel(ctx)`, and apply the same fix in the `Update`, `Delete` and `DeleteCollection` goroutines.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:106

Delete success metric uses object name as label, causing unbounded cardinality — Using `name` as a label value creates one metric series per deleted object, which means unbounded cardinality and metrics inconsistent with other calls. Pass `options.Kind` instead, and use the enriched `log` rather than `d.Log` when setting the context logger.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:134-141

Async legacy update uses raw objInfo instead of the object Storage persisted — Passing the raw `objInfo` lets `Legacy.Update` recompute the change against its own old copy after the request ends, so legacy can store different content than Storage. Wrap the result as `updateWrapper{upstream: objInfo, updated: res}` before the goroutine and pass that to `Legacy.Update`.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:43-47

Failed storage Create recorded as legacy duration instead of storage duration — Recording a failed Storage create with `recordLegacyDuration` pollutes the legacy metrics and leaves the storage error metric empty. Call `recordStorageDuration(true, ...)` instead. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:127-131` - `pkg/apiserver/rest/dualwriter_mode3.go:161-167`

Gold bugs found (4)

mediumDelete's success path records the storage metric with the object name in the kind label instead of options.Kind, creating per-object series and inconsistent labels.
mediumOn storage Create/Update failure the duration is recorded with recordLegacyDuration, attributing unified-store errors to the legacy metric.
highMode 3 legacy writes now run in background goroutines derived from the request context, which is cancelled when the request completes, so legacy writes can be cancelled and legacy storage falls out of sync.
highLegacy.Update now receives the original objInfo instead of a wrapper carrying the object stored in unified storage, so legacy recomputes the update and can diverge.

Gold bugs missed (5)

mediumThe legacy DeleteCollection goroutine records its duration with recordStorageDuration instead of recordLegacyDuration, misattributing legacy latency and errors to the storage metric.
mediumThe Mode 3 tests never wait for or assert the asynchronous legacy writes, and legacy and storage share one mock, so removing the legacy calls would not fail them.
highIndependent per-request goroutines remove ordering between legacy writes to the same resource, so legacy can end up with an older version or a resurrected object.
mediumMode 3 legacy-storage write errors (create/update/delete/delete-collection) are no longer logged after moving to async goroutines; only a duration metric with an error flag is recorded.
highDualWriterMode3.Delete now returns on any unified-storage error, including NotFound, before deleting from legacy, so objects that exist only in legacy can no longer be deleted.