fix(vuln): drop vestigial UNIQUE on unified-vuln tables to prevent refresh freeze #51
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Motstandskraft/spam!51
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/unified-vuln-indexes-nonunique"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Worker logs show duplicate-key failures identical in shape to the cluster_summary freeze:
Why it freezes
Both objects are plain tables (converted from matviews in
20260430), maintained byDELETE + INSERT … SELECT(RebuildDerivedTables/ExtractDerivedOnArrivalininternal/db/derived_tables.go) — noON CONFLICTanywhere. TheirUNIQUEindexes were only ever required by the oldREFRESH MATERIALIZED VIEW CONCURRENTLY, which no longer runs, so they're vestigial.They are not harmless, though: any duplicate row the feeding
SELECTemits raises a23505that aborts the wholeINSERT, the extract errors,recordMaterializedViewRefreshis skipped, the<table>:wmwatermark never advances, and the derived vuln tables freeze fleet-wide until a manual rebuild. This is the same abort-and-freeze class as the cluster_summarycluster_idcollision (PR #49 /20260710).Fix
Recreate both indexes as plain (non-unique). Safe because every read path re-aggregates these tables down to
canonical_id(internal/vulnmetrics/metrics.go, thevuln_canonical_*/asset_riskviews), so end-result counts are unchanged (the20260430conversion comment says exactly this). The plain index preserves the(repo_id|image_id, vuln_id, …)lookup/filter performance, and theDISTINCT ONin the*_scopedfunctions remains as belt-and-suspenders dedup.Verification
go vet ./cmd/server/...— clean.DROP INDEX IF EXISTS+CREATE INDEX IF NOT EXISTS, safe to replay.Related
🤖 Generated with Claude Code
addee49f182ed32314b7