index_vulnerability_identifiers_on_name_where_cve synchronous database index addition

Summary

This issue is to add a migration to create the index_vulnerability_identifiers_on_name_where_cve database index synchronously after it has been created asynchronously on GitLab.com.

The asynchronous index was introduced to fix cache-miss CPU spikes on the Sec production Patroni cluster caused by unindexed CVE-name lookups on vulnerability_identifiers. See #617135 (closed) for the investigation and query plans.

CREATE INDEX CONCURRENTLY index_vulnerability_identifiers_on_name_where_cve
ON vulnerability_identifiers USING btree (name)
WHERE (lower((external_type)::text) = 'cve');

Steps

  1. Verify the async index was created on GitLab.com (ChatOps: /chatops gitlab run auto_deploy status <merge_sha> should return db/gprd, or query postgres_async_indexes/pg_indexes directly).
  2. Add a post-deploy migration that calls add_concurrent_index for the same index (prepare_async_index already records the definition; the sync migration must match it exactly) and remove it from postgres_async_indexes.
Edited by 🤖 GitLab Bot 🤖