Gitlab 故障处理 - 对象文件为空(object-file-is-empty)解决方案


Gitlab 故障处理 - 对象文件为空(object-file-is-empty)解决方案

最优解决方案
/var/opt/gitlab/git-data/repositories/

1.运行 git fsck --full
切换到对应的空间目录,gitlab.bwt18.com 打开页面为500的空间,如本次故障 http://gitlab.bwt18.com/BTGAME/NBTGAME
[root@gitlab ~]# cd /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:36:37&&125]# git fsck --full
error: object file .git/objects/3a/60046cdd45cf3e943d1294b3cb251a63fb9552 is empty
error: object file .git/objects/3a/60046cdd45cf3e943d1294b3cb251a63fb9552 is empty
fatal: loose object 3a60046cdd45cf3e943d1294b3cb251a63fb9552 (stored in .git/objects/3a/60046cdd45cf3e943d1294b3cb251a63fb9552) is corrupt

2. 运行 git fsck --full 一般会检查到另外一个新的空文件,再删之。
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:36:37&&125]# find ./ -size 0 -delete -print
./objects/94/f54cca620d11608d83b1829da390ebe8c61029
./objects/00/152fb0c58c9a656b7736402809e9628e74b7dd
./objects/f3/ca1cc08c5f49ba74dbdf9b12b8a0facaa60a45
./objects/3f/1c92cb614c76ea46413287d199ac172d14103e
./objects/3f/c88d755bc57c7183e1797408039831036e010c
./objects/c2/5846d9581e42c70a48abd85dba88e0563c8378
./objects/64/db82cf7725d4e48f4ed9a1885fd9ad346c39c0
./objects/cb/23e0f7eb3b3c10ba04c2ded4bd988d7e62a328
./objects/4b/26ffea2d813ab2161b50ec05d9d779f01ab3c9
./objects/7c/2fc42b07b43b4c8fda9200481a40f77eaafa96

3.至此,所有空文件删除完毕,再运行 git fsck --full,还是有错,head指向元素不存在,是之前一个空文件,我们已经删了。肿么办呢?
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:46:37&&125] git fsck --full
Checking object directories: 20% (53/256) 
Checking object directories: 21% (56/256)

Checking object directories: 22% (57/256)

Checking object directories: 44% (114/256)

Checking object directories: 100% (256/256), done.
error in commit d4c342a28756bfee13a5c2358e85a5f3c4290f0d: badEmail: invalid author/committer line - bad email
error in commit c0f93e61e63663c6d9fc083f7019d895488a77eb: badEmail: invalid author/committer line - bad email
Checking objects: 100% (503386/503386), done.
error: refs/heads/develop_20190926_APP-2910_hengban: invalid sha1 pointer eede72d8b32b4a97fc5608fd3d42b9517a0484ea
Checking connectivity: 128657

Checking connectivity: 583545, done.
dangling commit 3a14c01f3d8bc413f49d3eafb9586fe38eff50af
dangling commit 9b2ca07f8356fc67c5b0a879264c855e9ccc5196
dangling commit 272ec075a0088586a50a93b1118907c575a085f2
dangling commit 1f36206894c8209261c6130412c87438e8bfea22
dangling commit cc37c0c07690cc51f9ad80f35869f1843edcfb6e
dangling commit d641e00e5b85ded4a610ad8942595e2989c2f552
dangling commit 764420f722f1bdbd386dc35c087af07199b39639
dangling commit cd4aa0645890758c3ea79da784bce8307987f9a7
dangling commit 295800fed1b1fc2e860ed95789a3c9847efe467e
dangling commit fe63600a8fb842d15b605ca705f4afc8aa4af48f
dangling commit 1a72a0211ab5e931ec04b4e14329bb038cd17160

5. 从上面日志查看有问题的分支
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:24:00&&109]#tail -n 2 refs/heads/develop_20190926_APP-2910_hengban
eede72d8b32b4a97fc5608fd3d42b9517a0484ea
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:25:22&&111]#cat refs/heads/develop_20190926_APP-2910_hengban
eede72d8b32b4a97fc5608fd3d42b9517a0484ea
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:25:28&&112]#git show eede72d8b32b4a97fc5608fd3d42b9517a0484ea
fatal: bad object eede72d8b32b4a97fc5608fd3d42b9517a0484ea
只有一条日志信息,查看大小
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:32:29&&121]#du -sh refs/heads/develop_20190926_APP-2910_hengban
4.0K refs/heads/develop_20190926_APP-2910_hengban
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:32:35&&122]#mv refs/heads/develop_20190926_APP-2910_hengban /tmp

6. 再次允许git fsck 
[root@gitlab /var/opt/gitlab/git-data/repositories/BTGAME/NBTGAME.git 03:32:58&&124]#git fsck --full

恢复正常
如果不为空,可以尝试如下方式处理,则可以参考网络上的一些方法

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM