I upgraded a self-managed, Omnibus, CE installation from 14.10.3 to 15.0.0 on a CentOS 7.9 system and I’m having problems with database migration. When I run
sudo gitlab-rake gitlab:check
I’m told
Database config exists? ... yes
All migrations up? ... no
Try fixing it:
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
Please fix the error above and rerun the checks.
When I attempt to run the migration using the suggested command, I get
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo: bundle: command not found
When I try to migrate using
sudo gitlab-rake db:migrate
I get
== 20220412135446 AddUniqueFingerprintSha256IndexToKey: migrating =============
-- transaction_open?()
-> 0.0000s
-- index_exists?(:keys, :fingerprint_sha256, {:unique=>true, :name=>"index_keys_on_fingerprint_sha256_unique", :algorithm=>:concurrently})
-> 0.0054s
-- Index being recreated because the existing version was INVALID: table_name: keys, column_name: fingerprint_sha256
-- transaction_open?()
-> 0.0000s
-- indexes(:keys)
-> 0.0027s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- remove_index(:keys, {:algorithm=>:concurrently, :name=>"index_keys_on_fingerprint_sha256_unique"})
-> 0.0598s
-- execute("RESET statement_timeout")
-> 0.0003s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- add_index(:keys, :fingerprint_sha256, {:unique=>true, :name=>"index_keys_on_fingerprint_sha256_unique", :algorithm=>:concurrently})
-- execute("RESET statement_timeout")
-> 0.0002s
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::UniqueViolation: ERROR: could not create unique index "index_keys_on_fingerprint_sha256_unique"
DETAIL: Key (fingerprint_sha256)=(****************************************)) is duplicated.
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:167:in `block in add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:388:in `disable_statement_timeout'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:166:in `add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20220412135446_add_unique_fingerprint_sha256_index_to_key.rb:10:in `up'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/lock_retry_mixin.rb:36:in `ddl_transaction'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: could not create unique index "index_keys_on_fingerprint_sha256_unique"
DETAIL: Key (fingerprint_sha256)=(***************************************)) is duplicated.
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:167:in `block in add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:388:in `disable_statement_timeout'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:166:in `add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20220412135446_add_unique_fingerprint_sha256_index_to_key.rb:10:in `up'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/lock_retry_mixin.rb:36:in `ddl_transaction'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Caused by:
PG::UniqueViolation: ERROR: could not create unique index "index_keys_on_fingerprint_sha256_unique"
DETAIL: Key (fingerprint_sha256)=(************************************)) is duplicated.
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:167:in `block in add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:388:in `disable_statement_timeout'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migration_helpers.rb:166:in `add_concurrent_index'
/opt/gitlab/embedded/service/gitlab-rails/db/migrate/20220412135446_add_unique_fingerprint_sha256_index_to_key.rb:10:in `up'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/lock_retry_mixin.rb:36:in `ddl_transaction'
/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)
Not sure what to do to remedy this. Any suggestions greatly appreciated.