Amazon Ergo 1.0 · Balanced
dual-storage-architecture-grafana-codex
Grafana · Go · L · 300–799 lines · 4 files
The normal review, with one generalist agent. Judge: Claude Opus 5.5.
- Gold bugs found
- 7 of 11
- Comments published
- 8
- Comments matching a bug
- 7
- Comments not matching
- 1
- Cost of this PR
- $1.685
Published comments (8)
Delete now returns on every storage error, including NotFound — Returning immediately from `Delete` strands objects that exist only in legacy storage, so they may reappear when reads switch back. Preserve the `apierrors.IsNotFound` fallthrough to the legacy delete.
Mode-3 legacy writes inherit the request context and are canceled on return — The apiserver cancels `ctx` when the handler returns, so fire-and-forget legacy writes can abort early and silently lose the mode-3 backup. Use `context.WithoutCancel(ctx)` before `context.WithTimeoutCause` in all four legacy writes.
Mode 3 legacy update bypasses the object written by Storage — Passing raw `objInfo` lets `Legacy.Update` re-run `UpdatedObject` against its own old object, so storage-assigned/defaulted fields or create-on-update behavior can diverge and break the backup. Restore `updateWrapper{upstream: objInfo, updated: res}`.
Storage duration metric uses object name as kind label — Unbounded Prometheus label cardinality can exhaust metric storage as object names vary, and the reported kind is wrong. Pass `options.Kind` instead of `name` to `recordStorageDuration`.
Mode-3 dual-write tests actually run in mode 1 — These tests can pass without exercising this PR's mode-3 code because `SetDualWritingMode` only transitions between modes 1 and 2 and returns `Mode1` for a fresh store. Seed the mode-3 transition and assert the active mode in the test helper.
Legacy DeleteCollection latency recorded via recordStorageDuration in mode 3 — Mode-3 legacy metrics misleadingly attribute backup latency and failures to unified storage, hiding legacy `DeleteCollection` problems. Call `recordLegacyDuration` instead of `recordStorageDuration` in that goroutine.
Mode 3 Create and Update record storage errors as legacy — Failed unified-storage writes are reported as legacy errors and no storage duration is recorded, hiding storage failures in mode-3 metrics. Replace `recordLegacyDuration(true, ...)` with `recordStorageDuration` in both the `Create` and `Update` error paths.
Unbounded legacy-write goroutines can exhaust goroutines and connections — Legacy slowdowns can accumulate goroutines and concurrent database writes for up to 10 seconds, exhausting resources because the old synchronous path no longer applies backpressure. Bound `Create`, `Update`, `Delete`, and `DeleteCollection` with a worker queue or concurrency limit.