Skip to content

reconfiguration failed after update from 18.0.2 to 18.1 with PG::UniqueViolation: ERROR

Summary

I tried to update my 18.0.2 install to GitLab 18.1 and ended up with DB migration errors.

Steps to reproduce

apt update && apt dist-upgrade

What is the current bug behavior?

Generated at 2025-06-19 21:23:08 +0200
Mixlib::ShellOut::ShellCommandFailed: 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: rake aborted!
StandardError: An error has occurred, all later migrations canceled:

PG::UniqueViolation: ERROR:  could not create unique index "index_merge_request_diff_commit_users_on_org_id_name_email"
DETAIL:  Key (organization_id, name, email)=(1, Thomas Lüder, t.lueder@nets.de) is duplicated.

Relevant logs and/or screenshots

cinc-stacktrace.out

Results of GitLab environment info

Output after the restore to 18.0.2

Expand for output related to GitLab environment info

System information
System:         Ubuntu 24.04
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   3.2.5
Gem Version:    3.6.7
Bundler Version:2.6.5
Rake Version:   13.0.6
Redis Version:  7.2.7
Sidekiq Version:7.3.9
Go Version:     unknown

GitLab information
Version:        18.0.2-ee
Revision:       073fca15cf9
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     16.8
URL:            https://XXXXXXX.dev
HTTP Clone URL: https://XXXXXXX.dev/some-group/some-project.git
SSH Clone URL:  git@XXXXXXX.dev:some-group/some-project.git
Elasticsearch:  no
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers: google_oauth2

GitLab Shell
Version:        14.42.0
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.0.2
- default Git Version:  2.49.0.gl2
- 

Results of GitLab application Check

Output after the restore to 18.0.2

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.42.0 ? ... OK (14.42.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Checking Reply by email ...

IMAP server credentials are correct? ... Checking servicedesk@XXXXXXX.dev 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 6/3 ... yes 4/4 ... yes 4/5 ... yes 7/6 ... yes 4/7 ... yes 4/8 ... yes 4/9 ... yes 5/10 ... yes 8/11 ... yes 8/12 ... yes 9/13 ... yes 10/14 ... yes 11/15 ... yes 11/16 ... yes 12/17 ... yes 12/18 ... yes 13/19 ... yes 14/20 ... yes 15/21 ... yes 15/22 ... yes 15/23 ... yes 15/24 ... yes 15/25 ... yes 15/26 ... yes 16/27 ... yes 16/28 ... yes 16/29 ... yes 16/30 ... yes 16/31 ... yes 17/32 ... yes 17/33 ... yes 17/34 ... yes 18/35 ... yes 19/36 ... yes 19/37 ... yes 19/38 ... yes 19/39 ... yes 20/40 ... yes 21/41 ... yes 22/42 ... yes 23/43 ... yes 24/44 ... yes 26/45 ... yes 25/46 ... yes 25/47 ... yes 25/48 ... yes 25/49 ... yes 25/50 ... yes 25/51 ... yes 25/52 ... yes 25/53 ... yes 25/54 ... yes 25/55 ... yes 27/56 ... yes 27/57 ... yes 28/58 ... yes 28/59 ... yes 28/60 ... yes 28/61 ... yes 28/62 ... yes 29/63 ... yes 30/64 ... yes 32/65 ... yes 32/66 ... yes 32/67 ... yes 32/68 ... yes 32/69 ... yes 32/70 ... yes 31/71 ... yes 33/72 ... yes 33/73 ... yes 33/74 ... yes 33/75 ... yes 33/76 ... yes 33/77 ... yes 33/78 ... yes 33/79 ... yes 33/80 ... yes 34/81 ... yes 35/82 ... yes 36/83 ... yes 36/84 ... yes 36/85 ... yes 37/86 ... yes 37/87 ... yes 37/88 ... yes 38/89 ... yes 38/90 ... yes 38/91 ... yes 38/92 ... yes 38/93 ... yes 38/94 ... yes 40/95 ... yes 40/96 ... yes 40/97 ... yes 39/98 ... yes 39/99 ... yes 41/100 ... yes 42/102 ... yes 162/103 ... yes 162/104 ... yes 42/105 ... yes 42/106 ... yes 42/107 ... yes 42/108 ... yes 42/109 ... yes 162/110 ... yes 42/111 ... yes 42/112 ... yes 42/113 ... yes 42/114 ... yes 42/115 ... yes 42/116 ... yes 42/117 ... yes 42/118 ... yes 42/119 ... yes 44/120 ... yes 44/121 ... yes 44/122 ... yes 162/123 ... yes 162/124 ... yes 162/125 ... yes 162/126 ... yes 162/127 ... yes 162/128 ... yes 162/129 ... yes 162/130 ... yes 162/131 ... yes 162/132 ... yes 162/134 ... yes 162/135 ... yes 162/136 ... yes 162/137 ... yes 162/138 ... yes 162/141 ... yes 162/142 ... yes 162/143 ... yes 162/145 ... yes 162/146 ... yes 162/147 ... yes 162/148 ... yes 162/149 ... yes 162/150 ... yes 163/151 ... yes 163/152 ... yes 164/153 ... yes 164/154 ... yes 165/155 ... yes 166/156 ... yes 171/157 ... yes 171/158 ... yes 171/159 ... yes 171/160 ... yes 171/161 ... yes 171/162 ... yes 172/163 ... yes 173/164 ... yes 173/165 ... yes 173/166 ... yes 173/167 ... yes 173/168 ... yes 173/169 ... yes 173/170 ... yes 239/173 ... yes 226/174 ... yes 2/175 ... yes 2/176 ... yes 162/177 ... yes 42/178 ... yes 260/181 ... yes 266/183 ... yes 33/184 ... yes 267/185 ... yes 173/186 ... yes 42/187 ... yes 272/188 ... yes 42/189 ... yes 162/190 ... yes 162/191 ... yes 277/192 ... yes 277/193 ... yes 42/194 ... yes 277/195 ... yes 171/196 ... yes 277/197 ... yes 162/198 ... yes 25/199 ... yes 291/201 ... yes 171/202 ... yes 291/203 ... yes 291/204 ... yes 291/205 ... yes 301/207 ... yes 303/208 ... yes 304/209 ... yes 21/210 ... yes 317/211 ... yes 303/212 ... yes 303/213 ... yes 301/214 ... yes 2/215 ... yes 328/216 ... yes 304/218 ... yes 303/219 ... yes 303/220 ... yes 303/223 ... yes 303/224 ... yes 320/225 ... yes 304/226 ... yes 13/227 ... yes 342/228 ... yes 342/229 ... yes 342/230 ... yes 303/231 ... yes 4/232 ... yes 328/233 ... yes 2/236 ... yes 1/237 ... yes 171/238 ... yes 303/239 ... yes 303/240 ... yes 319/241 ... yes Redis version >= 6.2.14? ... yes Ruby version >= 3.0.6 ? ... yes (3.2.5) Git user has default SSH configuration? ... yes Active users: ... 39 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

Same problems during restore

While restoring 18.0.2 and importing the backup DB that was created just before the update I encountered some other kind of same issues.

2025-06-19 20:09:23 UTC -- ------ BEGIN ERRORS -----

2025-06-19 20:09:23 UTC -- ERROR:  could not create unique index "index_ci_refs_on_project_id_and_ref_path"
DETAIL:  Key (project_id, ref_path)=(136, refs/heads/change/bordabc) is duplicated.
ERROR:  could not create unique index "index_merge_request_diff_commit_users_on_name_and_email"
DETAIL:  Key (name, email)=(Thomas Lüder, t.lueder@nets.de) is duplicated.
ERROR:  could not create unique index "index_programming_languages_on_name"
DETAIL:  Key (name)=(HTML) is duplicated.
ERROR:  could not create unique index "index_software_licenses_on_unique_name"
DETAIL:  Key (name)=(BSD with attribution) is duplicated.

2025-06-19 20:09:23 UTC -- ------ END ERRORS -------

I've deleted the create index from the DB dump and was able to import it.

But how is this possible, that I can't restore a DB dump that was just created from the same postgresql version?

Edited by 🤖 GitLab Bot 🤖