Skip to content

Remove duplicate rows from `vulnerability_occurrences` table

Summary

During work on #212322 (closed) it came to our attention that the current logic in Security::StoreReportService will result in entries for which our method of calculating UUIDv5 will yield duplicate values. This is would violate the CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occurrences USING btree (uuid); constraint present in the database.

We need to remove rows that would result in duplicate UUIDv5 values

Implementation plan

  • database Create a post-deployment migration that:
    • Has timestamp lower than 20201112130715
    • Creates an index on (project_id, report_type, location_fingerprint, primary_identifier_id, id)
    • Drops the duplicates using EachBatch
    • Removes the index on (project_id, report_type, location_fingerprint, primary_identifier_id, id)
Edited by Michał Zając