Skip to content

WIP: Cleanup moved gitlab-foss issues script(DO NOT MERGE)

Felipe Cardozo requested to merge disable_old_issues_script into master

DO NOT MERGE

This is a script to cleanup issues in gitlab-foss repository, for more information check: #31808 (closed)

This merge request got created so we can review and improve the script before running it on staging/production and should be closed after it.

Script details

It removes milestone, weight, due_date, epic and labels from the old issues.

Since we have 16782 moved issues the script prevents sending the milestone removed email and creating 5 system notes for each one.

Query used to fetch the moved issues:

gitlabhq_production=> 
explain analyze SELECT * FROM "issues" WHERE "issues"."id" IN (SELECT "notes"."noteable_id" FROM "notes" WHERE
"notes"."project_id" = 13083 AND "notes"."noteable_type" = 'Issue' AND (created_at >= '2019-09-09') AND 
(note LIKE '%GitLab is moving all development for both GitLab Community Edition%')) \g

QUERY PLAN                                           
                                              
---------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------
 Nested Loop  (cost=14301.69..14304.73 rows=1 width=774) (actual time=15324.101..15541.953 rows=16782 loops=1)
   ->  HashAggregate  (cost=14301.25..14301.26 rows=1 width=4) (actual time=15324.056..15333.438 rows=16782 loops=1)
         Group Key: notes.noteable_id
         ->  Bitmap Heap Scan on notes  (cost=14221.97..14301.25 rows=1 width=4) (actual time=15200.234..15316.371 rows=16782 loops=1)
               Recheck Cond: ((note ~~ '%GitLab is moving all development for both GitLab Community Edition%'::text) AND (project_id = 13083)
 AND ((noteable_type)::text = 'Issue'::text))
               Rows Removed by Index Recheck: 7
               Filter: (created_at >= '2019-09-09 00:00:00+00'::timestamp with time zone)
               Rows Removed by Filter: 648
               Heap Blocks: exact=17482
               ->  BitmapAnd  (cost=14221.97..14221.97 rows=52 width=0) (actual time=15196.794..15196.795 rows=0 loops=1)
                     ->  Bitmap Index Scan on index_notes_on_note_trigram  (cost=0.00..1029.17 rows=13423 width=0) (actual time=14767.957..14
767.957 rows=19473 loops=1)
                           Index Cond: (note ~~ '%GitLab is moving all development for both GitLab Community Edition%'::text)
                     ->  Bitmap Index Scan on index_notes_on_project_id_and_noteable_type  (cost=0.00..13192.55 rows=716198 width=0) (actual 
time=417.821..417.821 rows=844873 loops=1)
                           Index Cond: ((project_id = 13083) AND ((noteable_type)::text = 'Issue'::text))
   ->  Index Scan using issues_pkey on issues  (cost=0.44..3.46 rows=1 width=774) (actual time=0.012..0.012 rows=1 loops=16782)
         Index Cond: (id = notes.noteable_id)
 Planning time: 3.893 ms
 Execution time: 15544.788 ms
Edited by Felipe Cardozo

Merge request reports