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)
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`.
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`
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`.
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.
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.
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`
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.
Legacy DeleteCollection latency recorded as storage metrics — Replace `recordStorageDuration` with `recordLegacyDuration` for the asynchronous legacy call.