DeepSeek V4.1 Flash · Balanced
dual-storage-architecture-grafana-codex
Grafana · Go · L · 300–799 lines · 4 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 6 of 9
- Comments published
- 6
- Comments matching a bug
- 6
- Comments not matching
- 0
- Cost of this PR
- $0.127
Published comments (6)
Async legacy writes use request context canceled after response — The legacy `Create`/`Update`/`Delete`/`DeleteCollection` run under the request context, which Go cancels as soon as `ServeHTTP` returns, so each aborts with `context.Canceled` right after the response and the dual write never happens. Detach the goroutine with `context.WithoutCancel(ctx)` while keeping request values.
Async legacy update reuses raw objInfo instead of persisted result — `Legacy.Update` re-invokes `objInfo.UpdatedObject` on the legacy store's own old object, so the legacy copy can diverge from unified storage. Wrap the persisted `res` in `updateWrapper` as modes 1 and 2 do and pass that to `d.Legacy.Update`.
Async legacy writes in mode 3 can be applied out of order per object — Fire-and-forget goroutines drop the ordering guarantee: a create-then-delete, as in `playlist_test.go:506-576`, can reach legacy reversed and leave the row orphaned. Serialize the async legacy writes per object with a single worker queue keyed by kind+name.
Legacy DeleteCollection records to storage histogram instead of legacy — Legacy latency lands in the storage histogram and legacy failures stay invisible in `grafana_dual_writer_legacy_duration_seconds`. Call `d.recordLegacyDuration`, as the other legacy calls do.
Delete storage duration metric uses object name as kind label — `recordStorageDuration` gets the object `name` in the `kind` label, so every deleted object adds a new `grafana_dual_writer_storage_duration_seconds` series (unbounded growth, unusable filtering). Pass `options.Kind` instead.
Create error path records legacy duration instead of storage duration — The storage failure goes to the legacy histogram, so `grafana_dual_writer_storage_duration_seconds` never shows `is_error=true` and legacy gets a false spike. Record it with `d.recordStorageDuration` instead. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:125-129`