Kimi K3.1 Pro · 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 Haiku 5.5.

Gold bugs found
8 of 9
Comments published
12
Comments matching a bug
8
Comments not matching
4
Cost of this PR
$2.743

Published comments (12)

mediumbugpkg/tests/apis/playlist/playlist_test.go:140-142

SetDualWritingMode cannot select mode 3, leaving new tests on mode 1 — New subtests can silently exercise `Mode1`, and fresh deployments cannot enable `Mode3`, because `SetDualWritingMode` initializes unset modes to `Mode1` and handles only 1↔2 transitions. Add explicit `Mode3` transitions and assert the selected mode.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:134-140

Legacy update resolves changes against the wrong old object — Patch/apply can produce different legacy contents whenever the stores differ because the original `objInfo` makes `d.Legacy.Update` resolve against its own old object instead of unified `res`. Pass an `updateWrapper` containing `res` and the upstream preconditions.

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

Unbounded legacy create goroutines can exhaust memory and connections — When legacy storage is slow, request-rate writes accumulate untracked goroutines and database work for up to the timeout, potentially exhausting memory or connections. Replace per-request spawning around `d.Legacy.Create` with a bounded worker queue that applies backpressure.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:153-157

Unified-storage errors skip legacy collection deletion — A transient unified-storage failure now leaves the entire legacy collection untouched instead of preserving best-effort dual deletion. Attempt `d.Legacy.DeleteCollection` even when `d.Storage.DeleteCollection` fails, while returning the original unified-storage error.

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

Successful Mode3 writes do not verify the asynchronous legacy write — Dropping the legacy `Create` goroutine would still pass because `m.On(...)` only stubs the call and the goroutine is never awaited; `Delete`, `DeleteCollection`, and `Update` have the same gap. Synchronize on legacy completion and assert its invocation and arguments so a lost write fails.

mediumbugpkg/apiserver/rest/dualwriter_mode3_test.go:108-120

TestMode3_Get cannot distinguish legacy and unified storage reads — Sharing `m` between `legacyStoreMock` and `storageMock` lets a legacy `Get` satisfy the unified expectation and return `exampleObj`, so a regression still passes. Use separate mocks, verify the unified-storage call, and assert legacy `Get` was never called.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:50-56

Async legacy writes can be canceled when the request handler returns — The API server can cancel the request `ctx` when the handler returns, aborting a legacy safety write after unified storage has committed. Derive each write's timeout from `context.WithoutCancel(ctx)` to detach cancellation while retaining namespace and identity values.

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

Legacy writes can execute out of order and leave stale state — Independently scheduled legacy writes let a later update or delete overtake a create or older update; `legacyStorage.Update` can then return not found, and the delayed create can leave stale pre-update state. Serialize operations per object or use one ordered queue instead of scheduling each request independently.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:100-104

Storage NotFound errors skip legacy deletion in mode 3 — An object missing from unified storage but still present in legacy storage can no longer be cleaned up because every `d.Storage.Delete` error returns before `d.Legacy.Delete`. Preserve the `apierrors.IsNotFound(err)` fallback and attempt legacy deletion as before.

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:45

Unified-storage create failures are recorded as legacy metrics — Recording this failure in `DualWriterLegacyDuration` loses the unified-storage failure and attributes its latency to a backend that was never called. Use `recordStorageDuration` on this path instead of `recordLegacyDuration`. **Also found in:** - `pkg/apiserver/rest/dualwriter_mode3.go:129-129` - `pkg/apiserver/rest/dualwriter_mode3.go:127-130`

mediumbugpkg/apiserver/rest/dualwriter_mode3.go:166

Legacy delete-collection results are recorded in the wrong metrics — Recording the asynchronous legacy result in the unified-storage histogram mixes legacy latency and errors into storage metrics while omitting them from legacy metrics. Call `recordLegacyDuration` with `startLegacy` instead of `recordStorageDuration`.

mediumperformancepkg/apiserver/rest/dualwriter_mode3.go:106

Delete metrics use object names as the kind label — Using object `name` as the Prometheus `kind` label misaggregates per-kind delete metrics and creates an unbounded time series for every object name. Pass `options.Kind` to `recordStorageDuration`, matching the error path.

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

Gold bugs missed (1)

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.