GPT-6.1 Sol · 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.491

Published comments (7)

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

Request cancellation can abort background legacy writes — Request cancellation can interrupt legacy replication because `context.WithTimeoutCause(ctx, ...)` inherits the HTTP request lifetime, affecting `Create`, `Update`, `Delete`, and `DeleteCollection`. Derive each bounded background context from `context.WithoutCancel(ctx)` to preserve namespace and identity values without inheriting cancellation.

highbugpkg/apiserver/rest/dualwriter_mode3.go:139

Legacy update recomputes changes against potentially divergent state — Reevaluating `objInfo` against divergent legacy state can produce different PATCH results or fail after `Storage.Update` succeeds. Pass an `updateWrapper` containing `res` to `Legacy.Update` so legacy storage receives the committed authoritative object.

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

Detached legacy writes reorder mutations and can resurrect deleted objects — Independent goroutines can run `Legacy.Create` after a subsequent `Legacy.Delete`, resurrecting deleted objects, or apply updates in reverse order even for sequential requests. Preserve per-object mutation ordering across legacy operations, or keep those writes synchronous. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:108-113` - `pkg/apiserver/rest/dualwriter_mode3.go:134-140`

mediumbugpkg/apiserver/rest/dualwriter_mode3_test.go:51-54

Shared mocks let mode-3 tests pass when the wrong backend is called — The shared `mock.Mock` lets `Legacy.Create` satisfy expectations intended for `Storage.Create`, so incorrect backend selection can pass. Use separate mocks throughout the mode-3 tests and configure the unified-storage error case on the storage mock.

mediumbugpkg/apiserver/rest/dualwriter_mode3_test.go:345-353

Update success test never verifies the asynchronous legacy write — Removing the legacy-update goroutine would still pass because the success test only checks the synchronous result from `dw.Update`. Use a separate legacy mock, wait for its `Update` call with a bounded completion signal, and assert the invocation and arguments.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:106

Successful deletions use object names instead of kind in storage metrics — Passing `name` to `recordStorageDuration` creates a metric series per object and separates successful deletions from failures labeled with `options.Kind`. Pass `options.Kind` instead, matching the error and legacy paths.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:45

Mode 3 metrics attribute operations to the wrong storage backend — Recording `Storage.Create` and `Storage.Update` failures with `recordLegacyDuration`, and legacy `DeleteCollection` observations with `recordStorageDuration`, hides primary-store errors and misattributes secondary failures. Use `recordStorageDuration` for primary errors and `recordLegacyDuration` for background collection deletion. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:165-166`

Gold bugs found (6)

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

Gold bugs missed (3)

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