Relation has no current order and table has no primary key to be used as default order

Hello!

New to gitlab administration, I’ve tried to perform an upgrade into my docker-based installation. Unfortunately due to disk failure (bad sectors) upgrade didn’t finish correctly and now I’m facing a problem where I can’t even start gitlab.

Rerunning migrations fails with this error (same error can observe in puma and sidekiq logs):

root@gitlab:/# gitlab-rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
ActiveRecord::IrreversibleOrderError: Relation has no current order and table has no primary key to be used as default order
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:1232:in `reverse_sql_order'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:980:in `reverse_order!'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:149:in `last'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:21:in `last'
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/cacheable_attributes.rb:19:in `current_without_cache'
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/cacheable_attributes.rb:63:in `rescue in current'
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/cacheable_attributes.rb:51:in `current'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:60:in `uncached_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:42:in `ensure_application_settings!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:15:in `block in current_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/null_request_store.rb:34:in `fetch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/safe_request_store.rb:12:in `fetch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:15:in `current_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/banzai/filter/asset_proxy_filter.rb:40:in `initialize_settings'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:7:in `block in <top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:42:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:6:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:666:in `block in load_config_initializer'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:182:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:665:in `load_config_initializer'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in `block in <class:Engine>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `tsort_each_child'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:415:in `call'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `call'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:60:in `run_initializers'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:363:in `initialize!'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `block in require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:339:in `require_environment!'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:83:in `block in run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/opt/gitlab/embedded/bin/rake:23:in `load'
/opt/gitlab/embedded/bin/rake:23:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:476:in `exec'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:24:in `start'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'

Caused by:
ActiveRecord::IrreversibleOrderError: Relation has no current order and table has no primary key to be used as default order
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:1232:in `reverse_sql_order'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:980:in `reverse_order!'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:149:in `last'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/querying.rb:21:in `last'
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/cacheable_attributes.rb:19:in `current_without_cache'
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/cacheable_attributes.rb:55:in `current'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:60:in `uncached_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:42:in `ensure_application_settings!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:15:in `block in current_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/null_request_store.rb:34:in `fetch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/safe_request_store.rb:12:in `fetch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:15:in `current_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/banzai/filter/asset_proxy_filter.rb:40:in `initialize_settings'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:7:in `block in <top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:42:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:6:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:666:in `block in load_config_initializer'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/notifications.rb:182:in `instrument'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:665:in `load_config_initializer'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/engine.rb:624:in `block in <class:Engine>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `instance_exec'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:32:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:50:in `tsort_each_child'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:415:in `call'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:415:in `each_strongly_connected_component_from'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `call'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
/opt/gitlab/embedded/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/initializable.rb:60:in `run_initializers'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:363:in `initialize!'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `block in require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:339:in `require_environment!'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.7/lib/rails/application.rb:523:in `block in run_tasks_blocks'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:241:in `invoke_prerequisites'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:83:in `block in run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/opt/gitlab/embedded/bin/rake:23:in `load'
/opt/gitlab/embedded/bin/rake:23:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:63:in `load'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:63:in `kernel_load'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli/exec.rb:28:in `run'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:476:in `exec'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:24:in `start'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/opt/gitlab/embedded/lib/ruby/site_ruby/2.7.0/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment

How can I debug further about which table services are complaining and eventually restore it to proper state?