Background Migration FixNonExistingTimelogUsers NoMethodError: undefined method `id' for nil:NilClass
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When upgrading from 17.11.7 to 18.2.5 the background migration FixNonExistingTimelogUsers: timelogs fails with NoMethodError: undefined method `id' for nil:NilClass
Steps to reproduce
- Upgrade from 17.11.7 to 18.2.5 and monitor background migrations
What is the current bug behavior?
The Background Migration FixNonExistingTimelogUsers: timelogs fails.
Retrying it via admin Web Gui does not solve the issue.
Relevant logs and/or screenshots
sudo gitlab-rake --trace gitlab:background_migrations:finalize[FixNonExistingTimelogUsers,timelogs,id,'[]']
** Invoke gitlab:background_migrations:finalize (first_time)
** Invoke environment (first_time)
** Execute environment ** Execute gitlab:background_migrations:finalize
rake aborted!
NoMethodError: undefined method id' for nil:NilClass
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/background_migration/fix_non_existing_timelog_users.rb:12:in perform'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_wrapper.rb:77:in `execute_batched_migration_job'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_wrapper.rb:63:in `execute_job'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_wrapper.rb:50:in `execute_batch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_wrapper.rb:25:in `perform'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_runner.rb:30:in `run_migration_job'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_runner.rb:146:in `run_migration_while'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_runner.rb:80:in `finalize'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/background_migration/batched_migration_runner.rb:10:in `finalize'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/background_migrations.rake:72:in `finalize_migration'
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/background_migrations.rake:18:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `block in execute'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `each'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:279:in `execute'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/gitlab/embedded/bin/rake:25:in `load'
/opt/gitlab/embedded/bin/rake:25:in `<top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli/exec.rb:59:in `load'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli/exec.rb:59:in `kernel_load'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli/exec.rb:23:in `run'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli.rb:452:in `exec'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/vendor/thor/lib/thor.rb:538:in `dispatch'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli.rb:35:in `dispatch'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/cli.rb:29:in `start'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/exe/bundle:28:in `block in <top (required)>'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/bundler-2.6.5/exe/bundle:20:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `'
Tasks: TOP => gitlab:background_migrations:finalize
After retrying several times and waiting it is finally shown in gitlab web gui not as "Failed", but in "Finalizing" Status, but seems to be stuck in Finalizing now.
Results of GitLab environment info
gitlab-rake gitlab:env:info
System information System: Ubuntu 22.04 Current User: git Using RVM: no Ruby Version: 3.2.5 Gem Version: 3.6.9 Bundler Version:2.6.5 Rake Version: 13.0.6 Redis Version: 7.2.9 Sidekiq Version:7.3.9 Go Version: unknown
GitLab information Version: 18.2.5 Revision: c4dd332e718 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 16.8 URL: https://gitlab.marasystems.de`` HTTP Clone URL: https://gitlab.marasystems.de/some-group/some-project.git SSH Clone URL: git@gitlab.example.com:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers:``
GitLab Shell Version: 14.44.0 Repository storages:
default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Gitaly
default Address: unix:/var/opt/gitlab/gitaly/gitaly.socketdefault Version: 18.2.5default Git Version: 2.50.1.gl1

