Skip to content

Cleanup task system note renaming background migration

Mario Celi requested to merge 371410-cleanup-background-migration-again into master

What does this MR do and why?

  1. This was already introduced before in !98479 (merged)
  2. Because of gitlab-com/gl-infra/production#7804 (closed) we had to no-op both migrations in !99034 (merged)
  3. We discovered that the reason why the background migration was failing only in staging is that the staging DB had 2 gin trigram indexes on the notes.note column and we know how that can cause random timeouts when updating the table that contains the index.
  4. The index_notes_on_note_gin_trigram index was found in both dev and staging environments, so we dropped that index with !101103 (merged)
  5. The other gin index only existed on staging and it was called test (probably left overs from a long time ago test). So we dropped that one with gitlab-com/gl-infra/production#7883 (closed)
  6. After both indexes were gone, I was able to ensure the background migration in staging run and expected and had no more failing batches.
  7. Now the background migration is finalized in all environments so we can merge this MR that cleans up that migration that was introduced in 15.4

Migration Output

UP

bin/rails db:migrate
main: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: migrating
main: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: migrated (0.0382s)

main: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: migrating ======
main: -- transaction_open?()
main:    -> 0.0000s
main: -- indexes(:system_note_metadata)
main:    -> 0.0042s
main: -- current_schema()
main:    -> 0.0005s
main: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: migrated (0.0088s)

ci: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: migrating
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal].
ci: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: migrated (0.0001s)

ci: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: migrating ======
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- indexes(:system_note_metadata)
ci:    -> 0.0050s
ci: -- current_schema()
ci:    -> 0.0004s
ci: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: migrated (0.0082s)

DOWN

bin/rails db:rollback:main && br db:rollback:ci STEP=2
main: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: reverting ======
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:system_note_metadata, [:id, :action], {:where=>"action = 'task'", :name=>"tmp_index_system_note_metadata_on_id_where_task", :algorithm=>:concurrently})
main:    -> 0.0068s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- add_index(:system_note_metadata, [:id, :action], {:where=>"action = 'task'", :name=>"tmp_index_system_note_metadata_on_id_where_task", :algorithm=>:concurrently})
main:    -> 0.0063s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: reverted (0.0261s)

main: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: reverting
main: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: reverted (0.0005s)

ci: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: reverting ======
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- index_exists?(:system_note_metadata, [:id, :action], {:where=>"action = 'task'", :name=>"tmp_index_system_note_metadata_on_id_where_task", :algorithm=>:concurrently})
ci:    -> 0.0089s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0005s
ci: -- add_index(:system_note_metadata, [:id, :action], {:where=>"action = 'task'", :name=>"tmp_index_system_note_metadata_on_id_where_task", :algorithm=>:concurrently})
ci:    -> 0.0069s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0006s
ci: == 20221018193827 DropTmpIndexSystemNoteMetadataOnIdWhereTask: reverted (0.0290s)

ci: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: reverting
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal].
ci: == 20221018193635 EnsureTaskNoteRenamingBackgroundMigrationFinished: reverted (0.0001s)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #371410 (closed)

Merge request reports

Loading