Backfill notes that have null discussion_id
What does this MR do and why?
Fixes missing discussion_id
in notes
. This was caused by a bug that has already been fixed. So we just need to fix old data.
On GitLab.com, we need to update 25M rows:
gitlabhq_dblab=# SELECT COUNT(*) FROM notes WHERE discussion_id IS NULL;
count
----------
25156506
Migration output
== 20220420061439 AddNotesNullDiscussionIdTempIndex: migrating ================
-- transaction_open?()
-> 0.0000s
-- index_exists?(:notes, :id, {:where=>"discussion_id IS NULL", :name=>"tmp_index_notes_on_id_where_discussion_id_is_null", :algorithm=>:concurrently})
-> 0.0237s
-- execute("SET statement_timeout TO 0")
-> 0.0005s
-- add_index(:notes, :id, {:where=>"discussion_id IS NULL", :name=>"tmp_index_notes_on_id_where_discussion_id_is_null", :algorithm=>:concurrently})
-> 0.0063s
-- execute("RESET statement_timeout")
-> 0.0005s
== 20220420061439 AddNotesNullDiscussionIdTempIndex: migrated (0.0545s) =======
== 20220420061450 BackfillNullNoteDiscussionIds: migrating ====================
== 20220420061450 BackfillNullNoteDiscussionIds: migrated (0.0164s) ===========
== 20220420061450 BackfillNullNoteDiscussionIds: reverting ====================
== 20220420061450 BackfillNullNoteDiscussionIds: reverted (0.0000s) ===========
== 20220420061439 AddNotesNullDiscussionIdTempIndex: reverting ================
-- transaction_open?()
-> 0.0000s
-- indexes(:notes)
-> 0.0082s
-- execute("SET statement_timeout TO 0")
-> 0.0003s
-- remove_index(:notes, {:algorithm=>:concurrently, :name=>"tmp_index_notes_on_id_where_discussion_id_is_null"})
-> 0.0033s
-- execute("RESET statement_timeout")
-> 0.0003s
== 20220420061439 AddNotesNullDiscussionIdTempIndex: reverted (0.0166s) =======
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #346495 (closed)
Edited by Heinrich Lee Yu