Skip to content

Remove orphaned label links and add a foreign key constraint

Stan Hu requested to merge sh-remove-orphaned-label-links into master

On GitLab.com, there are over 2 million orphaned label links out of a total of 13 million. These orphaned label links can cause quiet failures, such as unexpected nil values in ExportCsvWorker.

It looks like about 1.4 million of these label links point to issues that no longer exist:

gitlabhq_production=# select count(*) from label_links where target_type = 'Issue' and not exists (SELECT 1 FROM issues where target_id = issues.id);
  count  
---------
 1443644
(1 row)

Closes gitlab-org/gitlab-ee#7482

Edited by Stan Hu

Merge request reports