V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ksc010
V2EX  ›  问与答

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

  •  
  •   ksc010 · 2021-12-07 16:07:20 +08:00 · 1169 次点击
    这是一个创建于 869 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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

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

    想问下还有的救不
    7 条回复    2021-12-07 18:03:05 +08:00
    ksc010
        1
    ksc010  
    OP
       2021-12-07 16:17:14 +08:00
    最近的一次备份是 上个月的,但是版本是 13.0.6 的。中间有几次提交,
    目前看最好的方案是不是只能 重新搭建一个新环境 恢复到这次的备份了
    ksc010
        2
    ksc010  
    OP
       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
        4
    ksc010  
    OP
       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
        5
    ksc010  
    OP
       2021-12-07 17:28:18 +08:00
    上面前四步 可以优化为

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

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

    在进入 docker 执行转换命令
    gadfly3173
        6
    gadfly3173  
       2021-12-07 17:55:15 +08:00
    13 升 14 要注意 14.0.x-14.1.x 附近几个小版本的兼容问题,如果备份数据丢的不多的话就开新的环境恢复吧
    ksc010
        7
    ksc010  
    OP
       2021-12-07 18:03:05 +08:00
    @gadfly3173 按照上面的方法 已经解决了 就是 “存储方式”转换失败的问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5058 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 01:12 · PVG 09:12 · LAX 18:12 · JFK 21:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.