Amazon Ergo 1.0 · 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 Opus 5.5.

Gold bugs found
8 of 11
Comments published
8
Comments matching a bug
8
Comments not matching
0
Cost of this PR
$2.773

Published comments (8)

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

Mode 3 legacy update re-applies UpdatedObjectInfo instead of stored object — The stores can persist different objects, or `Legacy.Update` can conflict, because it now calls `objInfo.UpdatedObject()` against legacy's own old object. Pass `updateWrapper` with `upstream: objInfo` and `updated: res` so legacy persists the object returned by `Storage.Update`.

highbugpkg/apiserver/rest/dualwriter_mode3.go:101-106

Mode 3 delete skips legacy cleanup when storage returns NotFound — Returning on every `Storage.Delete` error strands objects that exist only in legacy: the caller gets 404 while mode 3 reads never surface the leftover row. Tolerate `metav1.StatusReasonNotFound` and still attempt `Legacy.Delete`; continue returning all other errors. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:100-105`

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

Mode 3 async legacy writes inherit request cancellation — The request-scoped `ctx` can cancel the fire-and-forget legacy write as soon as the API call returns, often failing `d.Legacy.Create` with `context canceled` and silently breaking mode 3 dual-writes. Derive the timeout from `context.WithoutCancel(ctx)` (or keep legacy writes synchronous) in `Create`, `Delete`, `Update`, and `DeleteCollection`.

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

Mode 3 tests share one mock and cannot verify store routing — A method can call the wrong store while every test still passes because both stores share one `*mock.Mock` and the same `m.On(...)` expectation. Give `legacyStoreMock` and `storageMock` separate mocks, then assert per-store call counts and that the unused store was not called.

mediumbugpkg/apiserver/rest/dualwriter_mode3_test.go:63-75

Mode 3 success tests do not verify asynchronous legacy calls — A broken or removed legacy write would still pass because the success tests never wait for or assert the asynchronous `Legacy.Create`, `Legacy.Update`, `Legacy.Delete`, and `Legacy.DeleteCollection` calls. Synchronize on each legacy invocation and assert it occurred before the test ends.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:45

Create and Update storage error paths record legacy duration metrics — When `Storage.Create` or `Storage.Update` fails, the error is mislabeled as a legacy failure and the storage latency/error metric is lost. Replace `recordLegacyDuration` with `recordStorageDuration` on both error paths. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:129-129` - `pkg/apiserver/rest/dualwriter_mode3.go:125-132`

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:106

Delete records object name as the metric kind label — Using the object name as `kind` breaks per-kind aggregation and makes `dual_writer_storage_duration_seconds` cardinality grow with the number of deleted objects. Pass `options.Kind` instead of `name`, matching the other `Delete` paths.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:166

Legacy DeleteCollection latency recorded as storage metrics — Replace `recordStorageDuration` with `recordLegacyDuration` for the asynchronous legacy call.

Gold bugs found (8)

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.
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.
mediumTestMode3_Get and TestMode3_List share one mock.Mock between the legacy and storage mocks with identical method names, so they would still pass if Mode 3 read from LegacyStorage instead of Storage.

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.
mediumThe new Mode 3 playlist integration subtests set DualWriterDesiredModes to Mode3, but SetDualWritingMode defaults a fresh key to Mode1 and only handles Mode1<->Mode2 transitions, so the subtests silently run in Mode1 and Mode3 cannot be enabled through configuration.