Gitlab 进首页报错500 Whoops。 访问仓库错误码503

2022-05-26 08:05:11 浏览数 (2)

一、背景

可能由于机器突然断过电,或者系统问题。部署的Gitlab在某天运行时突然不正常,具体表现在通过浏览器进首页时报错(错误码为500),访问其中一个仓库错误码为503。如下:

后来发现无法备份,备份到某个仓库的时候会终止。

查了一圈有人说是由于断电导致某个文件损坏了,继而引发的问题。

版本:

系统:ubuntu16.04

GitLab版本:10.7.3

二、部分日志:

备份时的日志:(如下就是xxx_lib仓库出了问题)

xxx/TEST_Proj1 … [DONE] xxx/TEST_Proj1.wiki … [SKIPPED] xxx/xxx_lib … rake aborted! Gitlab::Git::CommandError: 13:HasLocalBranches: cmd wait: exit status 128 /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb:1397:in rescue in gitaly_migrate' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb:1390:ingitaly_migrate' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb:1546:in uncached_has_local_branches?' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb:240:inblock in has_local_branches?' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/utils/strong_memoize.rb:26:in strong_memoize' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/git/repository.rb:239:inhas_local_branches?' /opt/gitlab/embedded/service/gitlab-rails/app/models/repository.rb:512:in has_visible_content?' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/repository_cache_adapter.rb:17:inblock (2 levels) in cache_method' /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/repository_cache.rb:22:in `fetch'

访问首页时的日志:

Read fragment views/routes/55-20180725054749729480000/projects/36-20180725054749660386000/root/index/application_settings/1-20180505055609666165000/cross-project:true/v2.5/6e9f3ed1415f1c03e7a094b52c2ed709 (0.2ms) Read fragment views/routes/238-20190905112740764906000/projects/202-20190905112740761259000/root/index/application_settings/1-20180505055609666165000/cross-project:true/v2.5/6e9f3ed1415f1c03e7a094b52c2ed709 (0.3ms) Read fragment views/routes/425-20220419091855157945000/projects/373-20220419091855154119000/root/index/application_settings/1-20180505055609666165000/cross-project:true/v2.5/6e9f3ed1415f1c03e7a094b52c2ed709 (0.2ms) Read fragment views/routes/43-20180620033208948092000/projects/27-20180620033208941965000/root/index/application_settings/1-20180505055609666165000/cross-project:true/v2.5/6e9f3ed1415f1c03e7a094b52c2ed709 (0.1ms) Completed 500 Internal Server Error in 181ms (ActiveRecord: 12.2ms) ActionView::Template::Error (failed to parse loose object: invalid header): 19: - if project.creator && use_creator_avatar 20: = image_tag avatar_icon_for_user(project.creator, 40), class: "avatar s40", alt:'' 21: - else 22: = project_icon(project, alt: '', class: 'avatar project-avatar s40') 23: .project-details 24: %h3.prepend-top-0.append-bottom-0 25: = link_to project_path(project), class: 'text-plain' do lib/gitlab/git/repository.rb:1692:in target' lib/gitlab/git/repository.rb:1692:inblock in branches_filter' lib/gitlab/git/repository.rb:1690:in each' lib/gitlab/git/repository.rb:1690:ineach' lib/gitlab/git/repository.rb:1690:in map' lib/gitlab/git/repository.rb:1690:inbranches_filter' lib/gitlab/git/repository.rb:173:in `block in branches'

三、解决方法

0)先在本地把xxx_lib仓库备份好。

1)进入Gitlab的存放仓库的目录,找到指定的仓库清空。

/var/opt/gitlab/git-data/repositories/xxx_User/  (xxx_User为用户名)

在此文件夹中把 xxx_lib.git  和 xxx_lib.wiki.git删掉。类似于下面这样,这两个就是一个仓库的数据。

 2)删掉后,就可以通过浏览器访问这个仓库,只不过变成一个空仓库了。

四、总结

1)要定期备份。

2)存放代码的机器要可靠,包含不限于系统稳定性和电源稳定。

0 人点赞