gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

Posted 一葉知秋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):相关的知识,希望对你有一定的参考价值。

  gitlab可以成功clone和push,但是提交后的文件却无法查看。从页面上看的话只显示出500错误。

    

  查了下gitlab的日志

tail -f /var/log/gitlab/gitlab-rails/production.log

  显示如下异常:

Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at 2016-07-04 17:49:08 +0800
Processing by Projects::CommitController#show as html
  Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed 200 OK in 224ms (Views: 156.4ms | ActiveRecord: 14.7ms)
Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7/branches" for 14.23.93.99 at 2016-07-04 17:49:09 +0800
Processing by Projects::CommitController#branches as HTML
  Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed 500 Internal Server Error in 291ms (ActiveRecord: 3.1ms)

Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):
  lib/gitlab/popen.rb:23:in `popen\'
  app/models/repository.rb:648:in `refs_contains_sha\'
  app/models/repository.rb:664:in `branch_names_contains\'
  app/controllers/projects/commit_controller.rb:64:in `branches\'
  lib/gitlab/middleware/go.rb:16:in `call\'


Started GET "/gitlab/root/test/autocomplete_sources?type=Commit&type_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at 2016-07-04 17:49:10 +0800
Processing by ProjectsController#autocomplete_sources as JSON
  Parameters: {"type"=>"Commit", "type_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "namespace_id"=>"root", "id"=>"test"}
Completed 200 OK in 170ms (Views: 83.8ms | ActiveRecord: 9.9ms)
Started GET "/gitlab/root/test/notes?target_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7&target_type=commit&last_fetched_at=1467625748" for 14.23.93.99 at 2016-07-04 17:49:24 +0800
Processing by Projects::NotesController#index as JSON
  Parameters: {"target_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "target_type"=>"commit", "last_fetched_at"=>"1467625748", "namespace_id"=>"root", "project_id"=>"test"}
Completed 200 OK in 47ms (Views: 0.3ms | ActiveRecord: 3.6ms)

   查了下内存为2G,已经满足gitlab最小内存1G的要求。

[root@xxxxxx ~]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        63M        43M       9.7M       140M
-/+ buffers/cache:       1.6G       213M
Swap:           0B         0B         0B

  但是非常诡异的是swap为0,网上找了发现也有人遇到相应的问题。于是修改下swap的大小

[root@xxxx ~]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        63M        43M       9.7M       140M
-/+ buffers/cache:       1.6G       213M
Swap:           0B         0B         0B
[root@xxxx ~]# mkdir /swapfile
[root@xxxx ~]# cd /swapfile
[root@xxxx swapfile]# sudo dd if=/dev/zero of=swap bs=1024 count=2000000
2000000+0 records in
2000000+0 records out
2048000000 bytes (2.0 GB) copied, 39.1198 s, 52.4 MB/s
[root@xxxx swapfile]# sudo mkswap -f  swap
Setting up swapspace version 1, size = 1999996 KiB
no label, UUID=75b00bde-7aed-48f3-b373-126a2054ad26
[root@xxxx swapfile]# sudo swapon swap
swapon: /swapfile/swap: insecure permissions 0644, 0600 suggested.
[root@xxxx swapfile]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        93M        43M       1.2M        23M
-/+ buffers/cache:       1.7G       118M
Swap:         1.9G         0B       1.9G
[root@xxx swapfile]# 

   修改后再次查看,果断地出来了,记录于此。

以上是关于gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):的主要内容,如果未能解决你的问题,请参考以下文章

gitlab提交

gitlab本地创建空文件,之后关联仓库提交文件...

Gitlab 无法将恢复的分支与另一个分支合并

在 GitLab 上,如何比较两个不同提交的文件

使用 gitlab api 更新和提交文件

gitlab拉取项目后提交会保存自己的信息吗