Create user throws Internal error 500 on Gitlab 14.0.1


Cannot create new user: ERROR: operator does not exist: integer || bigint at character 330

Steps to reproduce

  1. Go to Admin page and click “New user” button
  2. Enter Name, Username and Email.
  3. Click Submit button
  4. You will see Internal error 500 on webpage.

What is the current bug behavior?

If you do gitlab-ctl tail, you will get the error

==> /var/log/gitlab/postgresql/current <==
2021-06-28_04:14:51.25224 ERROR:  operator does not exist: integer[] || bigint at character 330
2021-06-28_04:14:51.25234 HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
2021-06-28_04:14:51.25235 STATEMENT:  /*application:web,correlation_id:01F98D7EESF7W51AW1BMTZKQ9X,endpoint_id:Admin::UsersController#create*/ 
2021-06-28_04:14:51.25235 	            UPDATE namespaces
2021-06-28_04:14:51.25235 	            SET traversal_ids = cte.traversal_ids
2021-06-28_04:14:51.25235 	            FROM (WITH RECURSIVE cte(id, traversal_ids, cycle) AS (
2021-06-28_04:14:51.25236 	  VALUES(332, ARRAY[332], false)
2021-06-28_04:14:51.25236 	UNION ALL
2021-06-28_04:14:51.25236 	  SELECT, cte.traversal_ids ||, = ANY(cte.traversal_ids)
2021-06-28_04:14:51.25236 	  FROM namespaces n, cte
2021-06-28_04:14:51.25236 	  WHERE n.parent_id = AND NOT cycle
2021-06-28_04:14:51.25236 	)
2021-06-28_04:14:51.25237 	SELECT id, traversal_ids FROM cte
2021-06-28_04:14:51.25239 	) as cte
2021-06-28_04:14:51.25239 	            WHERE =
2021-06-28_04:14:51.25239 	              AND namespaces.traversal_ids <> cte.traversal_ids

and also the error:

==> /var/log/gitlab/gitlab-rails/production.log <==
ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  operator does not exist: integer[] || bigint
LINE 7:   SELECT, cte.traversal_ids ||, = ANY(cte.tra...
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
app/models/namespace/traversal_hierarchy.rb:43:in `block in sync_traversal_ids!'
lib/gitlab/database.rb:376:in `block in transaction'
lib/gitlab/database.rb:375:in `transaction'
app/models/namespace/traversal_hierarchy.rb:41:in `sync_traversal_ids!'
app/models/namespaces/traversal/linear.rb:116:in `sync_traversal_ids'
app/services/users/create_service.rb:16:in `execute'
lib/gitlab/metrics/instrumentation.rb:160:in `block in execute'
lib/gitlab/metrics/method_call.rb:27:in `measure'
lib/gitlab/metrics/instrumentation.rb:160:in `execute'
app/controllers/admin/users_controller.rb:179:in `create'
app/controllers/application_controller.rb:487:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:478:in `set_session_stora

Results of GitLab environment info

System information
System:		Ubuntu 20.04
Current User:	git
Using RVM:	no
Ruby Version:	2.7.2p137
Gem Version:	3.1.4
Bundler Version:2.1.4
Rake Version:	13.0.3
Redis Version:	6.0.14
Git Version:	2.32.0
Sidekiq Version:5.2.9
Go Version:	unknown

GitLab information
Version:	14.0.1
Revision:	76b84b42f64
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	12.6
SSH Clone URL:
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	13.19.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.19.0 ? ... OK (13.19.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/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: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... 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
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...  YES 
Redis version >= 5.0.0? ... yes
Ruby version >= 2.7.2 ? ... yes (2.7.2)
Git version >= 2.31.0 ? ... yes (2.32.0)
Git user has default SSH configuration? ... yes
Active users: ... 71
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes for All

Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished

ALTER TABLE namespaces ALTER COLUMN id TYPE integer; fixed the issue