Error 500 - Exception: Invalid single-table inheritance type: User is not a subclass of Namespace

Hi all,

I have some issue after my attempt to upgrade to 14.6.x from 14.0 and realized that there’s an additional steps and can’t simply upgrade directly :frowning:

I also tried to rollback to last useable version but stuck due to unfinished batched job which then I marked as complete in order to proceed.

Unfortunately, it’s stuck after Google Auth, and when I trace using the gitlab-ctl tail, I found out there an error stated that :

==> /var/log/gitlab/gitlab-rails/production.log <==

ActiveRecord::SubclassNotFound (Invalid single-table inheritance type: User is not a subclass of Namespace):

app/models/user.rb:1459:in ensure_namespace_correct' app/services/users/update_service.rb:27:in execute’
app/services/users/update_service.rb:36:in execute!' lib/gitlab/auth/o_auth/user.rb:55:in save’
lib/gitlab/auth/o_auth/user.rb:85:in `find_and_update!’

Further checking using gitlab:check :

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: …
tests / gearman … yes
John Doe / aircolony … Exception: Invalid single-table inheritance type: User is not a subclass of Namespace
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: … 60
Is authorized keys file accessible? … yes
GitLab configured to store new projects in hashed storage? … yes
All projects are in hashed storage? … yes

Is there anyone that encounter the same error ? How can I delete John Doe user that seems like the main issue here.

Thanks in advance

I am also getting the same error after upgrading from 14.6.2. Were you able to solve it?

I am getting the same error.
I was on 14.1.3 and now upgraded to 14.1.8.

gitlab_1  | ==> /var/log/gitlab/gitlab-rails/production_json.log <==
gitlab_1  | {"method":"POST","path":"/users/sign_in","format":"html","controller":"SessionsController","action":"create","status":500,"time":"2022-05-12T21:01:56.347Z","params":[{"key":"authenticity_token","value":"[FILTERED]"},{"key":"user","value":{"login":"root","password":"[FILTERED]","remember_me":"0"}}],"remote_ip":"192.168.0.99","user_id":null,"username":null,"ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36","correlation_id":"01G2X181KX1NB1A15X2SQ5W5G5","meta.caller_id":"SessionsController#create","meta.remote_ip":"192.168.0.99","meta.feature_category":"authentication_and_authorization","meta.client_id":"ip/192.168.0.99","redis_calls":2,"redis_duration_s":0.000459,"redis_read_bytes":277,"redis_write_bytes":128,"redis_cache_calls":1,"redis_cache_duration_s":0.000289,"redis_cache_read_bytes":203,"redis_cache_write_bytes":43,"redis_shared_state_calls":1,"redis_shared_state_duration_s":0.00017,"redis_shared_state_read_bytes":74,"redis_shared_state_write_bytes":85,"db_count":14,"db_write_count":5,"db_cached_count":1,"cpu_s":0.085272,"mem_objects":17363,"mem_bytes":1110432,"mem_mallocs":3693,"mem_total_bytes":1804952,"exception.class":"ActiveRecord::SubclassNotFound","exception.message":"Invalid single-table inheritance type: User is not a subclass of Namespace","exception.backtrace":["app/models/user.rb:1459:in `ensure_namespace_correct'","app/controllers/concerns/impersonation.rb:13:in `current_user'","app/controllers/application_controller.rb:164:in `block in auth_user'","lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'","app/controllers/application_controller.rb:163:in `auth_user'","app/controllers/application_controller.rb:147:in `append_info_to_payload'","lib/gitlab/middleware/speedscope.rb:13:in `call'","lib/gitlab/request_profiler/middleware.rb:17:in `call'","lib/gitlab/jira/middleware.rb:19:in `call'","lib/gitlab/middleware/go.rb:20:in `call'","lib/gitlab/etag_caching/middleware.rb:21:in `call'","lib/gitlab/middleware/multipart.rb:172:in `call'","lib/gitlab/middleware/read_only/controller.rb:50:in `call'","lib/gitlab/middleware/read_only.rb:18:in `call'","lib/gitlab/middleware/same_site_cookies.rb:27:in `call'","lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'","lib/gitlab/middleware/basic_health_check.rb:25:in `call'","lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'","lib/gitlab/middleware/request_context.rb:21:in `call'","config/initializers/fix_local_cache_middleware.rb:11:in `call'","lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'","lib/gitlab/metrics/requests_rack_middleware.rb:74:in `call'","lib/gitlab/middleware/release_env.rb:12:in `call'"],"db_duration_s":0.03256,"view_duration_s":0.0,"duration_s":0.11249}
gitlab_1  |
gitlab_1  | ==> /var/log/gitlab/gitlab-rails/production.log <==
gitlab_1  |
gitlab_1  | ActiveRecord::SubclassNotFound (Invalid single-table inheritance type: User is not a subclass of Namespace):
gitlab_1  |
gitlab_1  | app/models/user.rb:1459:in `ensure_namespace_correct'
gitlab_1  | app/controllers/concerns/impersonation.rb:13:in `current_user'
gitlab_1  | app/controllers/application_controller.rb:164:in `block in auth_user'
gitlab_1  | lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
gitlab_1  | app/controllers/application_controller.rb:163:in `auth_user'
gitlab_1  | app/controllers/application_controller.rb:147:in `append_info_to_payload'
gitlab_1  | lib/gitlab/middleware/speedscope.rb:13:in `call'
gitlab_1  | lib/gitlab/request_profiler/middleware.rb:17:in `call'
gitlab_1  | lib/gitlab/jira/middleware.rb:19:in `call'
gitlab_1  | lib/gitlab/middleware/go.rb:20:in `call'
gitlab_1  | lib/gitlab/etag_caching/middleware.rb:21:in `call'
gitlab_1  | lib/gitlab/middleware/multipart.rb:172:in `call'
gitlab_1  | lib/gitlab/middleware/read_only/controller.rb:50:in `call'
gitlab_1  | lib/gitlab/middleware/read_only.rb:18:in `call'
gitlab_1  | lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
gitlab_1  | lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
gitlab_1  | lib/gitlab/middleware/basic_health_check.rb:25:in `call'
gitlab_1  | lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
gitlab_1  | lib/gitlab/middleware/request_context.rb:21:in `call'
gitlab_1  | config/initializers/fix_local_cache_middleware.rb:11:in `call'
gitlab_1  | lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
gitlab_1  | lib/gitlab/metrics/requests_rack_middleware.rb:74:in `call'
gitlab_1  | lib/gitlab/middleware/release_env.rb:12:in `call'
root@git:/# gitlab-rake gitlab:check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.19.1 ? ... OK (13.19.1)
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: ...
integration / scripts ... yes

Om / updater... Exception: Invalid single-table inheritance type: User is not a subclass of Namespace
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: ... 29
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

root@git:/#

Can someone help?
Please

Having same issue after recreating a gitlab container. Any solution?

@Gitlab Team,

Please help.
It is affecting our developers.

I also get this error. Upgraded from 14.0.22 to 14.1.0 and this happened.
Found a solution?

Did we get any solution for this issue. Am also facing same error