18.8.4 to 18.9.0 Update Failed PG::CheckViolation: ERROR: check constraint "check_ddd6f289f4" of relation "commit_user_mentions" is violated by some row
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Upgrading from 18.8.4 -> 18.9.0 Database migrations fail caused by null constraint on "commit_user_mentions"
Reinstalled 18.8.4.
Steps to reproduce
Ensure any background migrations completed. Upgrade from 18.8.4-ee -> 18.9.9-ee observe PG::CheckViolation
PG::CheckViolation: ERROR: check constraint "check_ddd6f289f4" of relation "commit_user_mentions" is violated by some row
Example Project
What is the current bug behavior?
Upgrade fails
What is the expected correct behavior?
Upgrade succeeds
Relevant logs and/or screenshots
rails_migration[gitlab-rails] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: bash_hide_env[migrate gitlab-rails database] (gitlab::database_migrations line 20) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash" ----
STDOUT: [WARNING] Object storage for ci_secure_files must have a bucket specified
Skipping Topology Service health check due to the cell being disabled
Running db:migrate rake task
main: == [advisory_lock_connection] object_id: 74360, pg_backend_pid: 149919
main: == 20260126165544 ValidateCommitUserMentionsNamespaceIdNotNullConstraint: migrating
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0006s
main: -- execute("ALTER TABLE commit_user_mentions VALIDATE CONSTRAINT check_ddd6f289f4;")
main: -- execute("RESET statement_timeout")
main: == [advisory_lock_connection] object_id: 74360, pg_backend_pid: 149919
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/timeout_helpers.rb:33:in `ensure in disable_statement_timeout'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/timeout_helpers.rb:33:in `disable_statement_timeout'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/constraints_helpers.rb:119:in `validate_check_constraint'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/constraints_helpers.rb:235:in `validate_not_null_constraint'
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20260126165544_validate_commit_user_mentions_namespace_id_not_null_constraint.rb:9:in `up'
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 20.04 Proxy: no Current User: git Using RVM: no Ruby Version: 3.2.8 Gem Version: 3.7.1 Bundler Version:2.7.1 Rake Version: 13.0.6 Redis Version: 7.2.11 Sidekiq Version:7.3.9 Go Version: unknown GitLab information Version: 18.8.4-ee Revision: 24b860ec8f9 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 16.11 URL: REDACTED HTTP Clone URL: REDACTED SSH Clone URL: REDACTED Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: google_oauth2 GitLab Shell Version: 14.45.5 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Gitaly - default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 18.8.4 - default Git Version: 2.52.GIT
Results of GitLab application Check
Expand for output related to the GitLab application check
[WARNING] Object storage for ci_secure_files must have a bucket specified Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.45.5 ? ... OK (14.45.5) Running /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-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: ... Checking Reply by email ...
IMAP server credentials are correct? ... Checking REDACTED yes Mailroom enabled? ... skipped MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes Tables are truncated? ... skipped All migrations up? ... yes 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: ... 3/1 ... yes 3/2 ... yes 3/3 ... yes 3/4 ... yes 3/5 ... yes 3/6 ... yes 3/7 ... yes 3/9 ... yes 3/10 ... yes 3/11 ... yes 3/12 ... yes 2/14 ... yes 3/15 ... yes 8/16 ... yes 8/17 ... yes 8/18 ... yes 3/19 ... yes 3/20 ... yes 3/23 ... yes 3/24 ... yes 3/36 ... yes 3/37 ... yes 3/38 ... yes 3/39 ... yes 2/40 ... yes 3/41 ... yes 2/42 ... yes 3/43 ... yes 3/44 ... yes 2/45 ... yes 2/46 ... yes 3/48 ... yes 3/49 ... yes 3/50 ... yes 3/51 ... yes 3/52 ... yes 3/53 ... yes 3/54 ... yes 3/55 ... yes 8/56 ... yes 3/57 ... yes 2/58 ... yes 2/59 ... yes 2/60 ... yes 3/61 ... yes 3/62 ... yes 3/63 ... yes 3/64 ... yes 3/65 ... yes 3/66 ... yes 3/67 ... yes 8/68 ... yes 3/69 ... yes 3/70 ... yes 8/71 ... yes 3/72 ... yes 3/76 ... yes 3/77 ... yes 3/78 ... yes 3/80 ... yes 16/81 ... yes 3/82 ... yes 24/83 ... yes 3/84 ... yes 3/85 ... yes 3/86 ... yes 24/87 ... yes 3/88 ... yes 3/89 ... yes 3/90 ... yes 3/91 ... yes 3/92 ... yes 3/93 ... yes 24/94 ... yes 8/95 ... yes 3/96 ... yes 3/97 ... yes 8/98 ... yes 3/99 ... yes 3/100 ... yes 3/102 ... yes 3/103 ... yes 8/104 ... yes 8/105 ... yes 45/107 ... yes 45/108 ... yes 8/109 ... yes 3/111 ... yes 3/112 ... yes 3/113 ... yes 3/114 ... yes 27/115 ... yes 33/117 ... yes 3/118 ... yes 3/119 ... yes 3/120 ... yes 27/121 ... yes 3/122 ... yes 3/123 ... yes 55/124 ... yes 55/125 ... yes 3/126 ... yes 16/127 ... yes 3/128 ... yes 3/129 ... yes 3/130 ... yes 10/131 ... yes 3/132 ... yes 37/133 ... yes 3/134 ... yes 4/135 ... yes 3/136 ... yes 3/137 ... yes 3/138 ... yes 3/140 ... yes 3/141 ... yes 8/143 ... yes 3/144 ... yes 3/145 ... yes 197/146 ... yes 3/147 ... yes 3/148 ... yes 3/149 ... yes 3/150 ... yes 3/151 ... yes 3/152 ... yes 3/154 ... yes 3/155 ... yes 3/156 ... yes 3/158 ... yes 3/159 ... yes 3/160 ... yes 3/161 ... yes 3/162 ... yes 3/163 ... yes Redis version >= 6.2.14? ... yes Ruby version >= 3.0.6 ? ... yes (3.2.8) Git user has default SSH configuration? ... yes Active users: ... 21 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-9.x or OpenSearch version 1.x-3.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
Patch release information for backports
If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.
Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.
High-severity bug remediation
To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.