NoMethodError: undefined method `commit' for nil:NilClass in sidekiq caused by a merge commit in a forked project with upstream project deleted.
Summary
This is reported by customer https://gitlab.my.salesforce.com/00161000017upDb.
When MR is merged in a forked project with the upstream project already deleted the sidekiq job ProcessCommitWorker
will be dead with error of NoMethodError: undefined method 'commit' for nil:NilClass
.
Steps to reproduce
- Make TeamA/repo with some initial commit
- Fork to TeamB/repo
- Delete TeamA/repo
- Make some commit to TeamB/repo (may not be necessary)
- Make a new branch to TeamB/repo and push
- Make an MR to merge to trunk
- Merge the MR
Example Project
N/A
What is the current bug behavior?
Sidekiq job ProcessCommitWorker
will be dead with error of NoMethodError: undefined method
commit' for nil:NilClass`.
What is the expected correct behavior?
No error.
Relevant logs and/or screenshots
2018-04-20_09:22:08.85675 2018-04-20T09:22:08.856Z 48040 TID-ouya2qb7g ProcessCommitWorker JID-fe6fe86b080fac1ed58632c4 INFO: Adding dead ProcessCommitWorker job fe6fe86b080fac1ed58632c4
2018-04-20_09:22:08.85734 2018-04-20T09:22:08.857Z 48040 TID-ouya2qb7g ProcessCommitWorker JID-fe6fe86b080fac1ed58632c4 INFO: fail: 0.008 sec
2018-04-20_09:22:08.85755 2018-04-20T09:22:08.857Z 48040 TID-ouya2qb7g WARN: {"context":"Job raised exception","job":{"class":"ProcessCommitWorker","args":[124,1,{"id":"3e34cb3082616430c2149c35e626a5057665589e","message":"Merge branch 'testb' into 'master'\n\nUpdate README.md with issue\n\nCloses #1\n\nSee merge request gitlab-org/security-test!2","parent_ids":["b2a473d4b2fb561e9bbb8fadb65b1dcd6bac7f3f","fc0602a8c807a5e94f0d9e2140240c7f1a1ca7d0"],"authored_date":"2018-04-20 17:19:34 +0800","author_name":"Administrator","author_email":"admin@example.com","committed_date":"2018-04-20 17:19:34 +0800","committer_name":"Administrator","committer_email":"admin@example.com"},true],"retry":3,"queue":"process_commit","jid":"fe6fe86b080fac1ed58632c4","created_at":1524215974.504662,"enqueued_at":1524216128.8486679,"error_message":"undefined method `commit' for nil:NilClass","error_class":"NoMethodError","failed_at":1524215974.5188632,"retry_count":2,"retried_at":1524216048.0001528},"jobstr":"{\"class\":\"ProcessCommitWorker\",\"args\":[124,1,{\"id\":\"3e34cb3082616430c2149c35e626a5057665589e\",\"message\":\"Merge branch 'testb' into 'master'\\n\\nUpdate README.md with issue\\n\\nCloses #1\\n\\nSee merge request gitlab-org/security-test!2\",\"parent_ids\":[\"b2a473d4b2fb561e9bbb8fadb65b1dcd6bac7f3f\",\"fc0602a8c807a5e94f0d9e2140240c7f1a1ca7d0\"],\"authored_date\":\"2018-04-20 17:19:34 +0800\",\"author_name\":\"Administrator\",\"author_email\":\"admin@example.com\",\"committed_date\":\"2018-04-20 17:19:34 +0800\",\"committer_name\":\"Administrator\",\"committer_email\":\"admin@example.com\"},true],\"retry\":3,\"queue\":\"process_commit\",\"jid\":\"fe6fe86b080fac1ed58632c4\",\"created_at\":1524215974.504662,\"enqueued_at\":1524216128.8486679,\"error_message\":\"undefined method `commit' for nil:NilClass\",\"error_class\":\"NoMethodError\",\"failed_at\":1524215974.5188632,\"retry_count\":2,\"retried_at\":1524216048.0001528}"}
2018-04-20_09:22:08.85764 2018-04-20T09:22:08.857Z 48040 TID-ouya2qb7g WARN: NoMethodError: undefined method `commit' for nil:NilClass
2018-04-20_09:22:08.85770 2018-04-20T09:22:08.857Z 48040 TID-ouya2qb7g WARN: /opt/gitlab/embedded/service/gitlab-rails/app/workers/process_commit_worker.rb:84:in `commit_exists_in_upstream?'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/service/gitlab-rails/app/workers/process_commit_worker.rb:19:in `perform'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:188:in `execute_job'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:170:in `block (2 levels) in process'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_status/server_middleware.rb:5:in `call'
2018-04-20_09:22:08.85771 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
2018-04-20_09:22:08.85772 /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/request_store_middleware.rb:6:in `call'
2018-04-20_09:22:08.85772 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
2018-04-20_09:22:08.85772 /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/sidekiq_middleware/shutdown.rb:52:in `call'
2018-04-20_09:22:08.85772 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
2018-04-20_09:22:08.85772 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/server/active_record.rb:15:in `call'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sentry-raven-2.5.3/lib/raven/integrations/sidekiq.rb:7:in `call'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/middleware/chain.rb:133:in `invoke'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:169:in `block in process'
2018-04-20_09:22:08.85773 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:141:in `block (6 levels) in dispatch'
2018-04-20_09:22:08.85774 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:97:in `local'
2018-04-20_09:22:08.85774 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:140:in `block (5 levels) in dispatch'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq.rb:36:in `block in <module:Sidekiq>'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:136:in `block (4 levels) in dispatch'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:204:in `stats'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:131:in `block (3 levels) in dispatch'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_logger.rb:7:in `call'
2018-04-20_09:22:08.85775 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:130:in `block (2 levels) in dispatch'
2018-04-20_09:22:08.85776 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/job_retry.rb:72:in `global'
2018-04-20_09:22:08.85776 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:129:in `block in dispatch'
2018-04-20_09:22:08.85776 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:44:in `with_context'
2018-04-20_09:22:08.85776 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/logging.rb:38:in `with_job_hash_context'
2018-04-20_09:22:08.85776 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:128:in `dispatch'
2018-04-20_09:22:08.85777 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:168:in `process'
2018-04-20_09:22:08.85777 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:85:in `process_one'
2018-04-20_09:22:08.85777 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/processor.rb:73:in `run'
2018-04-20_09:22:08.85777 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:16:in `watchdog'
2018-04-20_09:22:08.85777 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:25:in `block in safe_thread'
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 14.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.3.6p384 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.3.0 Redis Version: 3.2.11 Git Version: 2.14.3 Sidekiq Version:5.0.5 Go Version: unknownGitLab information Version: 10.6.4-ee Revision: 42f072e Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.8 URL: https://gitlab.ee HTTP Clone URL: https://gitlab.ee/some-group/some-project.git SSH Clone URL: git@gitlab.ee:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: github, gitlab
GitLab Shell Version: 6.0.4 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 6.0.4 ? ... OK (6.0.4) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 1/14 ... ok 1/17 ... ok 1/18 ... ok 1/61 ... ok 39/64 ... ok 1/65 ... ok 1/66 ... ok 1/68 ... ok 42/73 ... ok 25/76 ... ok 42/78 ... ok 42/79 ... ok 1/80 ... ok 25/81 ... repository is empty 42/82 ... ok 1/83 ... ok 42/85 ... ok 42/86 ... ok 51/87 ... ok 42/88 ... ok 42/89 ... repository is empty 42/90 ... ok 25/91 ... ok 1/94 ... ok 1/95 ... ok 42/96 ... ok 40/97 ... repository is empty 1/98 ... ok 1/99 ... ok 57/104 ... ok 1/109 ... ok 25/111 ... ok 1/112 ... ok 1/113 ... ok 25/116 ... ok 1/118 ... ok 70/119 ... ok 1/121 ... ok 1/123 ... ok 39/124 ... ok 39/125 ... ok 39/127 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
IMAP server credentials are correct? ... yes Init.d configured correctly? ... skipped MailRoom running? ... skipped
Checking Reply by email ... Finished
Checking LDAP ...
Server: ldapmain Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead. Deprecation warning: Net::LDAP::ConnectionRefused will be deprecated. Use Errno::ECONNREFUSED instead. Could not connect to the LDAP server: Connection refused - connect(2) for 127.0.0.1:389
Checking LDAP ... Finished
Checking GitLab ...
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: ... 1/14 ... yes 1/17 ... yes 1/18 ... yes 1/61 ... yes 39/64 ... yes 1/65 ... yes 1/66 ... yes 1/68 ... yes 42/73 ... yes 25/76 ... yes 42/78 ... yes 42/79 ... yes 1/80 ... yes 25/81 ... yes 42/82 ... yes 1/83 ... yes 42/85 ... yes 42/86 ... yes 51/87 ... yes 42/88 ... yes 42/89 ... yes 42/90 ... yes 25/91 ... yes 1/94 ... yes 1/95 ... yes 42/96 ... yes 40/97 ... yes 1/98 ... yes 1/99 ... yes 57/104 ... yes 1/109 ... yes 25/111 ... yes 1/112 ... yes 1/113 ... yes 25/116 ... yes 1/118 ... yes 70/119 ... yes 1/121 ... yes 1/123 ... yes 39/124 ... yes 39/125 ... yes 39/127 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.3.6) Git version >= 2.9.5 ? ... yes (2.14.3) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1524217417 sudo mv /var/opt/gitlab/.ssh/id_rsa.pub ~/gitlab-check-backup-1524217417 sudo mv /var/opt/gitlab/.ssh/id_rsa ~/gitlab-check-backup-1524217417 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 10 Elasticsearch version 5.1 - 5.5? ... skipped (elasticsearch is disabled)
Checking GitLab ... Finished
Possible fixes
https://gitlab.com/gitlab-org/gitlab-ee/blob/master/app/workers/process_commit_worker.rb#L82
If a forked project gets the upstream project deleted, project.forked?
will still be true
but project.forked_from_project
will be nil
.