Restoring from backup does not restore hidden refs
Summary
When trying to open an old Merge Request (MR) that has already been merged, GitLab reports an error 500, but not for all merge requests. It seems that MR merged after a GitLab upgrade are ok. Only the MR merged on older version of GitLab have an issue.
The GitLab upgrade consisted of the following:
- GitLab 9.1.7 was migrated from host running Ubuntu 12.04 LTS to new host running Ubuntu 16.04 LTS using the backup/restore functions of GitLab.
- Then GitLab was upgraded from 9.1.7 to GitLab 9.5.5
The issue was just noticed, so this is not clear if it happened due to upgrade 1 or 2.
Steps to reproduce
The GitLab upgrade consisted of the following:
- GitLab 9.1.7 was migrated from host running Ubuntu 12.04 LTS to new host running Ubuntu 16.04 LTS using the backup/restore functions of GitLab.
- Then GitLab was upgraded from 9.1.7 to GitLab 9.5.5
What is the current bug behavior?
Cannot open old merge requests as we are getting error 500
What is the expected correct behavior?
Open old merge request as any other merge requests without error 500
Relevant logs and/or screenshots
production.log
Started GET "/Net/Net/merge_requests/616" for 172.16.50.164 at 2017-09-25 11:41:48 -0700
Processing by Projects::MergeRequestsController#show as HTML
Parameters: {"namespace_id"=>"Net", "project_id"=>"Net", "id"=>"616"}
Completed 500 Internal Server Error in 27ms (ActiveRecord: 2.5ms)
Rugged::ReferenceError (source repository is empty):
app/models/merge_request.rb:954:in `block in write_ref'
app/models/repository.rb:997:in `with_repo_branch_commit'
app/models/merge_request.rb:949:in `write_ref'
app/models/merge_request.rb:798:in `fetch_ref'
app/models/merge_request.rb:817:in `ensure_ref_fetched'
app/controllers/projects/merge_requests/application_controller.rb:16:in `ensure_ref_fetched'
lib/gitlab/i18n.rb:46:in `with_locale'
lib/gitlab/i18n.rb:52:in `with_user_locale'
app/controllers/application_controller.rb:326:in `set_locale'
lib/gitlab/middleware/multipart.rb:93:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:17:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
Results of GitLab environment info
System information
System: Ubuntu 16.04
Current User: git
Using RVM: no
Ruby Version: 2.3.5p376
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 12.0.0
Redis Version: 3.2.5
Git Version: 2.13.5
Sidekiq Version:5.0.4
Go Version: unknown
GitLab information
Version: 9.5.5
Revision: 3cf5eba
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: http://GitLabServer
HTTP Clone URL: http://GitLabServer/some-group/some-project.git
SSH Clone URL: git@GitLabServer:some-group/some-project.git
Using LDAP: yes
Using Omniauth: no
GitLab Shell
Version: 5.8.0
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
Checking GitLab Shell ...
GitLab Shell version >= 5.8.0 ? ... OK (5.8.0)
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: ...
6/3 ... ok
5/5 ... ok
5/7 ... ok
6/8 ... ok
6/9 ... ok
5/10 ... ok
25/11 ... ok
25/12 ... ok
25/13 ... repository is empty
24/14 ... ok
25/15 ... ok
25/17 ... ok
24/18 ... ok
24/19 ... ok
42/21 ... ok
42/22 ... ok
66/25 ... ok
66/26 ... ok
66/27 ... ok
66/28 ... ok
66/29 ... ok
66/30 ... ok
66/31 ... ok
66/32 ... ok
66/33 ... ok
66/34 ... ok
66/35 ... ok
66/36 ... ok
66/37 ... ok
66/38 ... ok
66/39 ... ok
66/40 ... ok
66/41 ... ok
66/42 ... ok
66/43 ... ok
66/44 ... ok
66/45 ... ok
66/46 ... ok
66/47 ... ok
50/48 ... ok
51/50 ... ok
25/51 ... ok
15/52 ... ok
5/53 ... ok
12/55 ... ok
12/56 ... ok
12/57 ... ok
12/58 ... ok
12/59 ... ok
6/60 ... ok
77/61 ... repository is empty
77/62 ... repository is empty
77/63 ... repository is empty
69/64 ... ok
7/65 ... ok
7/66 ... ok
15/67 ... ok
78/68 ... ok
85/69 ... repository is empty
42/70 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: 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 ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
DN: CN=userA,CN=Users,DC=Domain sAMAccountName: userA
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: ...
6/3 ... yes
5/5 ... yes
5/7 ... yes
6/8 ... yes
6/9 ... yes
5/10 ... yes
25/11 ... yes
25/12 ... yes
25/13 ... yes
24/14 ... yes
25/15 ... yes
25/17 ... yes
24/18 ... yes
24/19 ... yes
42/21 ... yes
42/22 ... yes
66/25 ... yes
66/26 ... yes
66/27 ... yes
66/28 ... yes
66/29 ... yes
66/30 ... yes
66/31 ... yes
66/32 ... yes
66/33 ... yes
66/34 ... yes
66/35 ... yes
66/36 ... yes
66/37 ... yes
66/38 ... yes
66/39 ... yes
66/40 ... yes
66/41 ... yes
66/42 ... yes
66/43 ... yes
66/44 ... yes
66/45 ... yes
66/46 ... yes
66/47 ... yes
50/48 ... yes
51/50 ... yes
25/51 ... yes
15/52 ... yes
5/53 ... yes
12/55 ... yes
12/56 ... yes
12/57 ... yes
12/58 ... yes
12/59 ... yes
6/60 ... yes
77/61 ... yes
77/62 ... yes
77/63 ... yes
69/64 ... yes
7/65 ... yes
7/66 ... yes
15/67 ... yes
78/68 ... yes
85/69 ... yes
42/70 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.3 ? ... yes (2.3.5)
Git version >= 2.7.3 ? ... yes (2.13.5)
Active users: ... 54
Checking GitLab ... Finished
Edited by Sean McGivern