Migration error while upgrading from 14.0 to 14.1

Hi,

I waited for background migrations to finish before I upgraded (14.0.12 → 14.1.7), but I still got an unexpected error during reconfigure.

Could someone help me ? Error below.

Edit: I tried removing this migration from the list, and while the reconfigure succeeded, I now have a 500 error and the following in the rails logs:

ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "integrations" does not exist
LINE 8:  WHERE a.attrelid = '"integrations"'::regclass
                            ^
):
    1: - return unless show_service_templates_deprecated_callout?
    2:
    3: - doc_link_start = "<a href=\"#{integrations_help_page_path}\" target='_blank' rel='noopener noreferrer'>".html_safe
    4: - settings_link_start = "<a href=\"#{integrations_admin_application_settings_path}\">".html_safe

Thanks.

    == 20210621043337 RenameServicesToIntegrations: migrating =====================
    -- execute("LOCK services IN ACCESS EXCLUSIVE MODE")
       -> 0.0013s
    -- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_insert ON services")
       -> 0.0011s
    -- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_update ON services")
       -> 0.0008s
    -- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_delete ON services")
       -> 0.0010s
    -- execute("DROP TRIGGER IF EXISTS trigger_has_external_issue_tracker_on_insert ON services")
       -> 0.0008s
    -- execute("DROP TRIGGER IF EXISTS trigger_has_external_issue_tracker_on_update ON services")rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
    
    PG::DuplicateTable: ERROR:  relation "integrations_id_seq" already exists
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:8:in `block in rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:121:in `run_block'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:130:in `block in run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:125:in `run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:95:in `run'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_helpers.rb:77:in `with_lock_retries'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:7:in `rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20210621043337_rename_services_to_integrations.rb:36:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `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>'
    
    Caused by:
    ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "integrations_id_seq" already exists
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:8:in `block in rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:121:in `run_block'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:130:in `block in run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:125:in `run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:95:in `run'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_helpers.rb:77:in `with_lock_retries'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:7:in `rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20210621043337_rename_services_to_integrations.rb:36:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `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>'
    
    Caused by:
    PG::DuplicateTable: ERROR:  relation "integrations_id_seq" already exists
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:8:in `block in rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:121:in `run_block'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:130:in `block in run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:125:in `run_block_with_lock_timeout'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/with_lock_retries.rb:95:in `run'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_helpers.rb:77:in `with_lock_retries'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/rename_table_helpers.rb:7:in `rename_table_safely'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20210621043337_rename_services_to_integrations.rb:36:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:405:in `block in transaction'
    /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database.rb:404:in `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

I solved it by removing the problematic relationship directly in the DB with DROP SEQUENCE integrations_id_seq;. I was then able to update to 14.4 successfully and evrything seems to work as expected. I hope nothing else got broken silently in the process.