自建的 gitlab,在最近的一次升级后发现部分仓库是空的了

2021-12-07 16:07:20 +08:00
 ksc010
web 点开后可以看到提交记录(这个应该是存到数据库中的)
但是没有任何文件,
repositories/[user]/[name] 下也都是空的 之前是 hash 文件的 我记得

但是 repositories 目录的总大小没有变化都是 3G
都跑到 repositories/@hashed/ 目录下 了

另外我发下 可以访问的 仓库 都提示 存储在 gitaly 上

Gitaly relative path: @hashed/89/aa/89/xxxxx.git


其他不能访问的 都是提示仓库是空

gitlab 目前版本是 14.4

我记得升级之前 有个提示 是 要切换 repositories 的存储方式 为 Hashed storage

也就是 repositories/[user]/[name] 切换为 repositories/@hashed/89/aa/89/xxxxx

当时升级后出错中断过,怀疑跟这次升级有关系

想问下还有的救不
1173 次点击
所在节点    问与答
7 条回复
ksc010
2021-12-07 16:17:14 +08:00
最近的一次备份是 上个月的,但是版本是 13.0.6 的。中间有几次提交,
目前看最好的方案是不是只能 重新搭建一个新环境 恢复到这次的备份了
ksc010
2021-12-07 16:55:10 +08:00
针对升级后提示 “NO REPOSITORY” 原因应该是

需要 将 legacy storage 转换为 hashed storage
执行命令 rake gitlab:storage:migrate_to_hashed

但是这个命令 我看了下 Admin->Monitoring->Background Jobs

hashed_storage:hashed_storage_project_migrate 队列中 实行失败了
ksc010
2021-12-07 17:05:14 +08:00
ksc010
2021-12-07 17:08:16 +08:00
在查看错误日志的的时候,会看到日志提示 “仓库只读”
然后就导致 转换过程失败了
这时候 手动把只读取消 然后重新执行转换命令就可以了


1. Start a Rails console session 75 (这里我是进入 docker 执行的 ./bin/rails console)
2. Find the project by name: p = Project.find_by_name("<project-name>")
3. Confirm that the repository is in fact read-only: p.repository_read_only
4. Unset the repository_read_only flag: p.update!(repository_read_only:nil)
5. Retry the corresponding Sidekiq job in the Admin Area (for me it would succeed almost instantly - the dead job count decreased and I never saw a running job)
6. Rinse and repeat from step 2.
ksc010
2021-12-07 17:28:18 +08:00
上面前四步 可以优化为

进入 数据库 (我用的是 postgreSql )

然后执行 update "projects" set repository_read_only = null where repository_read_only is true ;

在进入 docker 执行转换命令
gadfly3173
2021-12-07 17:55:15 +08:00
13 升 14 要注意 14.0.x-14.1.x 附近几个小版本的兼容问题,如果备份数据丢的不多的话就开新的环境恢复吧
ksc010
2021-12-07 18:03:05 +08:00
@gadfly3173 按照上面的方法 已经解决了 就是 “存储方式”转换失败的问题

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/820649

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX