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