Gitlab 14.0.0~14.0.4 버전에서 업그레이드 시 일괄 백그라운드 마이그레이션 실패로 인한 이슈

소스 버전 : 14.0.1

대상 버전 : 14.5.2

에러 코드 :

Caused by:Expected batched background migration for the given configuration to be marked as 'finished', but it is 'active': {:job_class_name=>"CopyColumnUsingBackgroundMigrationJob", :table_name=>"deployments", :column_name=>"id", :job_arguments=>[["deployable_id"], ["deployable_id_convert_to_bigint"]]} Finalize it manualy by running sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,deployments,id,'[["deployable_id"]\, ["deployable_id_convert_to_bigint"]]'] For more information, check the documentation <https://docs.gitlab.com/ee/user/admin_area/monitoring/background_migrations.html#database-migrations-failing-because-of-batched-background-migration-not-finished> /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:1124:in ensure_batched_background_migration_is_finished' /opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20210802131812_finalize_convert_deployments_bigint.rb:12:in up'/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/lock_retry_mixin.rb:31:in ddl_transaction' /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:61:in block (3 levels) in <top (required)>'/opt/gitlab/embedded/bin/bundle:23:in load' /opt/gitlab/embedded/bin/bundle:23:in <main>'Tasks: TOP => db:migrate(See full trace by running task with --trace) -- index_exists?(:issues, [:project_id, :state_id, :created_at, :id], {:name=>"index_issues_on_project_id_and_state_id_and_created_at_and_id", :algorithm=>:concurrently})-> 0.0054s-- execute("SET statement_timeout TO 0")-> 0.0001s-- add_index(:issues, [:project_id, :state_id, :created_at, :id], {:name=>"index_issues_on_project_id_and_state_id_and_created_at_and_id", :algorithm=>:concurrently})-> 0.0030s-- execute("RESET statement_timeout")-> 0.0001s== 20210802112233 AddIndexIssuesOnProjectIdAndStateIdAndCreatedAtAndId: migrated (0.0093s) == 20210802131812 FinalizeConvertDeploymentsBigint: migrating =================STDERR:---- End output of "bash" "/tmp/chef-script20211216-3963741-8n9png" ----Ran "bash" "/tmp/chef-script20211216-3963741-8n9png" returned 1 Running handlers completeChef Infra Client failed. 0 resources updated in 25 seconds

 

Caused by :

BatchedBackgroundMigrationWorkers 가 Self-hosted Gitlab에서 동작하지 않는 이슈로 인하여 버전 업그레이드 시 에러 발생

 

해결 방법 :

  1. 버그 패치 버전(14.0.5, 14.1.0)으로 먼저 버전 업그레이드 후 최신 버전으로 업그레이드

    1. Ref : Upgrading Linux package instances | GitLab

  2. 수동으로 마이그레이션 실행 후 Gitlab 재구성(될 때까지)

    $ sudo gitlab-rake gitlab:background_migrations:finalize[CopyColumnUsingBackgroundMigrationJob,deployments,id,'[["deployable_id"]\, ["deployable_id_convert_to_bigint"]]'] $ sudo gitlab-ctl reconfigure $ sudo gitlab-ctl restart

 

Ref : https://docs.gitlab.com/ee/user/admin_area/monitoring/background_migrations.html#database-migrations-failing-because-of-batched-background-migration-not-finished