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

Hello @Gitlab Team,

Suddenly we have started to get this error.
I have tried everything, like restarting the server, upgrading to a newer release, downgrading but not able to resolve this error.
Please assist.

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'

where you able to solve it?