GLM-5.3 Flash · 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
5 of 11
Comments published
6
Comments matching a bug
5
Comments not matching
1
Cost of this PR
$0.070

Published comments (6)

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

Async legacy write context killed when request context is cancelled — The goroutine's `context.WithTimeoutCause(ctx, ...)` inherits the request context, which is cancelled as soon as the handler returns, killing the legacy write and hiding the error. Detach it with `context.WithoutCancel(ctx)` and log the failure.

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

Async legacy update writes stale object instead of persisted unified result — Passing raw `objInfo` to `d.Legacy.Update` lets it write from legacy's stale copy, so mutations from `d.Storage.Update` (resourceVersion, generation) never reach the legacy backup. Wrap it as `&updateWrapper{upstream: objInfo, updated: res}`, as mode 2 does.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:43-48

Create/Update record storage errors as legacy durations — A failed `d.Storage.Create` is counted by `d.recordLegacyDuration`, polluting legacy metrics while the storage histogram never sees the error. Call `d.recordStorageDuration` here and in the matching `Update` path.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:161-167

DeleteCollection goroutine records legacy result in storage metric instead of legacy — Legacy delete-collection outcomes land in the storage histogram, leaving the legacy metric empty for this path. Record with `d.recordLegacyDuration` instead, as the sibling `Delete` goroutine does.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:106

Delete records storage duration with object name instead of kind label — Passing the object `name` as the `kind` label creates a new timeseries per deleted object, making the metric ungroupable and unbounded. Pass `options.Kind` like every other call site.

mediumbugpkg/tests/apis/playlist/playlist_test.go:132-144

Mode 3 async legacy writes make getFromBothAPIs assertions racy — Mode 3 writes to legacy asynchronously, so the immediate legacy GET in `getFromBothAPIs` can see a 404 or stale data and fail intermittently. Poll the legacy API until the write is visible before asserting cross-store equality.

Gold bugs found (5)

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.

Gold bugs missed (6)

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