Unable to restore Gitlab

Hi everyone,

I’m running gitlab on docker for more than 6 months without any problems. At each new update I was updating gitlab by pulling the latest image of gitlab. I was running the version 13.0.6 and this afternoon I have seen that there was a new version of gitlab, so I’ve updated my gitlab instance the same way as usual. But for whatever reason the new container created no longer wanted to function (when I was accessing directly gitlab (from the internal port) it was working but when accessing from nginx it was returning a 400 error).

So I decided to restore the latest backup (from midnight) unforntunately after executing gitlab-backup restore the container no longer boot with the following error:

ActiveRecord::IrreversibleOrderError: Relation has no current order and table has no primary key to be used as default order
/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:48:in `uncached_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:30:in `ensure_application_settings!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:7: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:7: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:5:in `block in <top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:5: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/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:48:in `uncached_application_settings'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:30:in `ensure_application_settings!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/current_settings.rb:7: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:7: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:5:in `block in <top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/asset_proxy_settings.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:5:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate:status => db:load_config => environment
(See full trace by running task with --trace)

Here is what I have done for restoring gitlab:

  • I’ve created a new folder on the server which contains 3 folder, config, data, logs
  • Then I create a new container docker run -d --hostname git.reyah.ga -p 22:22 -p 10081:80 --name gitlab2 --restart always -v /server/gitlab2/config:/etc/gitlab -v /server/gitlab2/logs:/var/log/gitlab -v /server/gitlab2/data:/var/opt/gitlab gitlab/gitlab-ce:13.0.6-ce.0
  • I copy the backup tar file in the folder data/backups
  • Once started (at this stage the gitlab server is accessible but obviously empty), I execute the restore docker exec -ti gitlab gitlab-backup restore
  • I copy the gitlab.rb and gitlab-secret.json from my backup
  • I restart the container with docker restart gitlab2

After restarting the container, it boot loop

Thanks in advance for any help

Have a look at this issue https://gitlab.com/gitlab-org/gitlab/-/issues/225883 it contains a few work around see if any of those work for you.