Upgrade 15.10.6 to 15.11.3 results in an error
Summary
Upgrading from 15.10.6 to 15.11.13 results into an error with a database migration
Steps to reproduce
- The starting version was 15.10.6
- There were no batched background migrations
- Tried to install 15.11.13 resulting in:
Running db:migrate rake task
main: == [advisory_lock_connection] object_id: 226960, pg_backend_pid: 725852
main: == 20230222161954 AddTextLimitToCustomJiraRegexFields: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE jira_tracker_data\nADD CONSTRAINT check_4cc5bbc801\nCHECK ( char_length(jira_issue_prefix) <= 255 )\nNOT VALID;\n")
STDERR:
---- End output of "bash" ----
Ran "bash" returned 1
What is the current bug behavior?
[~] # gitlab-rake db:migrate:down VERSION=20230222161954
main: == [advisory_lock_connection] object_id: 226860, pg_backend_pid: 1286008
main: == [advisory_lock_connection] object_id: 226860, pg_backend_pid: 1286008
[~] # gitlab-rake db:migrate:up VERSION=20230222161954
main: == [advisory_lock_connection] object_id: 226720, pg_backend_pid: 1286080
main: == 20230222161954 AddTextLimitToCustomJiraRegexFields: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE jira_tracker_data\nADD CONSTRAINT check_4cc5bbc801\nCHECK ( char_length(jira_issue_prefix) <= 255 )\nNOT VALID;\n")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::DuplicateObject: ERROR: constraint "check_4cc5bbc801" for relation "jira_tracker_data" already exists
What is the expected correct behavior?
Migration is a success
Relevant logs and/or screenshots
No data that is longer than 255 characters
gitlabhq => select * from jira_tracker_data;
id | created_at | updated_at | encrypted_url | encrypted_url_iv | encrypted_api_url | encrypted_api_url_iv | encrypted_username | encrypted_username_iv | encrypted_password | encr
ypted_password_iv | jira_issue_transition_id | project_key | issues_enabled | deployment_type | vulnerabilities_issuetype | vulnerabilities_enabled | jira_issue_transition_automati
c | integration_id | jira_issue_prefix | jira_issue_regex
----+------------+------------+---------------+------------------+-------------------+----------------------+--------------------+-----------------------+--------------------+-----
------------------+--------------------------+-------------+----------------+-----------------+---------------------------+-------------------------+-------------------------------
--+----------------+-------------------+------------------
(0 rows)
The constraint exists even though we've performed a migration:down
:
[~] # gitlab-rake db:migrate:down VERSION=20230222161954
main: == [advisory_lock_connection] object_id: 226860, pg_backend_pid: 1286008
main: == [advisory_lock_connection] object_id: 226860, pg_backend_pid: 1286008
[~] # gitlab-rake db:migrate:up VERSION=20230222161954
main: == [advisory_lock_connection] object_id: 226720, pg_backend_pid: 1286080
main: == 20230222161954 AddTextLimitToCustomJiraRegexFields: migrating ==============
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE jira_tracker_data\nADD CONSTRAINT check_4cc5bbc801\nCHECK ( char_length(jira_issue_prefix) <= 255 )\nNOT VALID;\n")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::DuplicateObject: ERROR: constraint "check_4cc5bbc801" for relation "jira_tracker_data" already exists
Table "public.jira_tracker_data"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
---------------------------------+--------------------------+-----------+----------+-----------------------------------------------+----------+--------------+-------------
id | bigint | | not null | nextval('jira_tracker_data_id_seq'::regclass) | plain | |
created_at | timestamp with time zone | | not null | | plain | |
updated_at | timestamp with time zone | | not null | | plain | |
encrypted_url | character varying | | | | extended | |
encrypted_url_iv | character varying | | | | extended | |
encrypted_api_url | character varying | | | | extended | |
encrypted_api_url_iv | character varying | | | | extended | |
encrypted_username | character varying | | | | extended | |
encrypted_username_iv | character varying | | | | extended | |
encrypted_password | character varying | | | | extended | |
encrypted_password_iv | character varying | | | | extended | |
jira_issue_transition_id | character varying | | | | extended | |
project_key | text | | | | extended | |
issues_enabled | boolean | | not null | false | plain | |
deployment_type | smallint | | not null | 0 | plain | |
vulnerabilities_issuetype | text | | | | extended | |
vulnerabilities_enabled | boolean | | not null | false | plain | |
jira_issue_transition_automatic | boolean | | not null | false | plain | |
integration_id | integer | | | | plain | |
jira_issue_prefix | text | | | | extended | |
jira_issue_regex | text | | | | extended | |
Indexes:
"jira_tracker_data_pkey" PRIMARY KEY, btree (id)
"index_jira_tracker_data_on_integration_id" btree (integration_id)
Check constraints:
"check_0bf84b76e9" CHECK (char_length(vulnerabilities_issuetype) <= 255)
"check_0fbd71d9f2" CHECK (integration_id IS NOT NULL)
"check_214cf6a48b" CHECK (char_length(project_key) <= 255)
"check_4cc5bbc801" CHECK (char_length(jira_issue_prefix) <= 255) NOT VALID
Foreign-key constraints:
"fk_c98abcd54c" FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE
Access method: heap
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 3.0.6p216 Gem Version: 3.2.33 Bundler Version:2.3.15 Rake Version: 13.0.6 Redis Version: 6.2.11 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 15.11.13-ee Revision: c2a3ebb864f Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.12 URL: https://gitlab-dev.groupemutuel.ch HTTP Clone URL: https://gitlab-dev.groupemutuel.ch/some-group/some-project.git SSH Clone URL: git@gitlab-dev.groupemutuel.ch:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.18.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.18.0 ? ... OK (14.18.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: FAILED - Internal API unreachable gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /opt/gitlab/embedded/service/gitlab-shell/config.yml Please fix the error above and rerun the checks.
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... no Try fixing it: sudo -u git -H RAILS_ENV=production bin/background_jobs start For more information see: doc/install/installation.md in section "Install Init Script" see log/sidekiq.log for possible errors Please fix the error above and rerun the checks.
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ... LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 100 users of 100 limit.
Checking LDAP ... Finished
Checking GitLab App ...
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. Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/5 ... yes 16/8 ... yes 19/9 ... yes 16/18 ... yes 16/19 ... yes 19/20 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (3.0.6) Git user has default SSH configuration? ... yes Active users: ... 3 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished Checking GitLab subtasks ... Finished
Possible fixes
We thought about manually dropping the constraint however considering this is an operation on the database itself we aren't sure if there are side-effects.