Avoid failing user deletion to block all ghost_user_migrations
What does this MR do and why?
Adds consume_after
column to the ghost_user_migrations
table. The column is used to reschedule failing user migration jobs, and to avoid a single failing job to block the entire queue.
Related to #377996 (closed).
Note: the new user deletion worker worker with limited execution time is behind the user_destroy_with_limited_execution_time_worker
feature flag.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Migration output
up
$ rake db:migrate:up:main VERSION=20221018124029
main: == 20221018124029 AddConsumeAfterToGhostUserMigrations: migrating =============
main: -- add_column(:ghost_user_migrations, :consume_after, :datetime_with_timezone, {:null=>false, :default=>#<Proc:0x000000001bdf8278 /home/ifarkas/code/gitlab-development-kit/gitlab/db/migrate/20221018124029_add_consume_after_to_ghost_user_migrations.rb:5 (lambda)>})
main: -> 0.0033s
main: == 20221018124029 AddConsumeAfterToGhostUserMigrations: migrated (0.0036s) ====
$ rake db:migrate:up:main VERSION=20221018124035
main: == 20221018124035 AddConsumeAfterIndexToGhostUserMigrations: migrating ========
main: -- transaction_open?()
main: -> 0.0000s
main: -- index_exists?(:ghost_user_migrations, :consume_after, {:name=>"index_ghost_user_migrations_on_consume_after", :algorithm=>:concurrently})
main: -> 0.0048s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- add_index(:ghost_user_migrations, :consume_after, {:name=>"index_ghost_user_migrations_on_consume_after", :algorithm=>:concurrently})
main: -> 0.0015s
main: -- execute("RESET statement_timeout")
main: -> 0.0004s
main: == 20221018124035 AddConsumeAfterIndexToGhostUserMigrations: migrated (0.0129s)
down
$ rake db:migrate:down:main VERSION=20221018124035
main: == 20221018124035 AddConsumeAfterIndexToGhostUserMigrations: reverting ========
main: -- transaction_open?()
main: -> 0.0000s
main: -- indexes(:ghost_user_migrations)
main: -> 0.0052s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- remove_index(:ghost_user_migrations, {:algorithm=>:concurrently, :name=>"index_ghost_user_migrations_on_consume_after"})
main: -> 0.0014s
main: -- execute("RESET statement_timeout")
main: -> 0.0002s
main: == 20221018124035 AddConsumeAfterIndexToGhostUserMigrations: reverted (0.0125s)
$ rake db:migrate:down:main VERSION=20221018124029
main: == 20221018124029 AddConsumeAfterToGhostUserMigrations: reverting =============
main: -- remove_column(:ghost_user_migrations, :consume_after, :datetime_with_timezone, {:null=>false, :default=>#<Proc:0x00000000199d4310 /home/ifarkas/code/gitlab-development-kit/gitlab/db/migrate/20221018124029_add_consume_after_to_ghost_user_migrations.rb:5 (lambda)>})
main: -> 0.0029s
main: == 20221018124029 AddConsumeAfterToGhostUserMigrations: reverted (0.0052s) ====
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
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.
Edited by Imre Farkas