Claude Sonnet 5.5 · Heavy

dual-storage-architecture-grafana-codex

Grafana · Go · L · 300–799 lines · 4 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
6 of 9
Comments published
7
Comments matching a bug
6
Comments not matching
1
Cost of this PR
$2.209

Published comments (7)

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

Async legacy create uses request context that is cancelled on handler return — The request `ctx` is cancelled when the handler returns, so the legacy `Create` (and the Update, Delete and DeleteCollection goroutines) can abort midway and desync the stores. Derive the timeout context from `context.WithoutCancel(ctx)`.

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

Async legacy Update reuses consumed objInfo instead of stored result — Legacy recomputes the object from its own old state instead of writing what `Storage.Update` produced, so the stores can diverge. Wrap `objInfo` and the stored result `res` in an `updateWrapper` before starting the goroutine.

mediumbugpkg/apiserver/rest/dualwriter_mode3_test.go:47-77

Mode3 Create test does not verify the asynchronous legacy write — The tests still pass if the goroutine calling `Legacy.*` is removed, because they only assert on the storage result. Wait with `assert.Eventually` or a channel signaled from the mock, and register legacy expectations in the Delete and DeleteCollection cases.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:96-106

Delete drops enriched logger from context and labels metric by object name — The context logger loses the name, kind and method values, and labeling the metric with `name` creates a new series per object. Pass `log` to `klog.NewContext` and use `options.Kind` in `recordStorageDuration`.

mediumperformancepkg/apiserver/rest/dualwriter_mode3.go:106

Object name passed as kind label to recordStorageDuration in Delete — Each distinct object name passed to `recordStorageDuration` creates a new Prometheus series, causing unbounded cardinality and memory growth. Pass `options.Kind`, as the other calls do.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:45

Create records storage failure with legacy duration metric — Storage failures in `Create` and `Update` are counted under `recordLegacyDuration`, which skews both metrics and hides storage errors. Use `recordStorageDuration` in both places. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:126-131` - `pkg/apiserver/rest/dualwriter_mode3.go:129-129`

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:166

Legacy DeleteCollection duration recorded as storage metric — Legacy latency and errors from `DeleteCollection` get mixed into the storage metrics. Call `recordLegacyDuration` instead of `recordStorageDuration`.

Gold bugs found (6)

mediumThe legacy DeleteCollection goroutine records its duration with recordStorageDuration instead of recordLegacyDuration, misattributing legacy latency and errors to the storage metric.
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.
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.

Gold bugs missed (3)

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.