Repository navigation
fix(db): drop the 8-column recommendations unique index so zonal EC2 AZ rows coexist (#792) - #811
Conversation
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 28 minutes for your next included review. View limit details
Comment |
Gate verdict: APPROVE at 6f48c67Independent review (Opus 5.5, claude-opus-5-5), merge gate for #792 PR2c. Review
Local verification (throwaway PostgreSQL 17.11 on 127.0.0.1,
Rollout
State at the SHA: all checks SUCCESS, mergeStateStatus CLEAN, labels mirror #792. |
Closes part of #792 (PR2c, the last step of the zonal EC2 AZ work).
What
000110drops the 8-columnrecommendations_natural_key_idx. The 9-columnrecommendations_natural_key_az_idx(000109) is now the only natural key, and the store already upserts on it (fix(config): upsert recommendations on the AZ-aware 9-column index #810). Two zonal EC2 rows that differ only by availability zone no longer abort the wholepersistCollectionwrite.collected_at), because the 8-column index cannot hold them. The table is a regenerable cache. Down is only safe together with a code rollback to the pre-fix(config): upsert recommendations on the AZ-aware 9-column index #810 8-columnON CONFLICT.Production runbook (order matters)
database-migration.ymlfor 000109 first (if not already applied in prod).ON CONFLICTneeds that index, so every collection would fail.Dev auto-migrates on merge.
Merge readiness
Not safe to merge until PR2b (#810, main commit 26470c3) is deployed to dev. At the time of writing the deploy workflows for that SHA (GCP, Azure, AWS) were still in progress, so dev still ran the old code. Merging earlier would auto-migrate dev under the 8-column upserter. Check the three deploy runs for 26470c3 are green first.
Tests (integration, against a throwaway local PostgreSQL 17; testcontainers hangs on this machine, so CI's testcontainers run is the authoritative one)
TestMigration_DropRecommendations8ColNaturalKey: index dropped, 9-column kept, AZ pair coexists, same-AZ and regional duplicates still rejected, down collapses AZ duplicates and recreates the 8-column index with its original definition, re-up works.TestPostgresStore_UpsertRecommendations_MultiAZBatch: two zonal rows in ONE batch upsert with no error and both persist; same-AZ re-upsert updates in place; regional row unaffected;ReplaceRecommendationsstores the pair.TestPersistCollectionMultiAZInOneBatch: a 500-row collection with two zonal recs on the same 8-tuple persists fully and records no write error.duplicate key ... recommendations_natural_key_idxand 0 rows stored.golangci-lint(go1.26.9) clean on the touched packages.Real-scenario evidence is a local Postgres 17 running the real migration chain and the real store path; no mocks. Not exercised: an actual AWS collection.
🤖 Generated with Claude Code