如何重新连接到head,此前曾处理过损坏的更新?

几个月前遇到了一些问题,最终不得不回退到 2.9.0.beta1,当时无法进一步更新。

由于各种特殊情况,我不得不暂时搁置这个项目,现在才得以重新开始。我发现根本问题在于 PostgreSQL 数据库服务器未得到充分且正确的升级,现在这个问题已解决,它运行在 PostgresQL 14.x 版本,Discourse 也正在使用此版本的数据库。

不幸的是,当我尝试通过常规的 Web 管理员升级用户界面进行升级时,它显示 fatal: HEAD does not point to a branch完整错误在此):

fatal: HEAD does not point to a branch
Docker Manager: FAILED TO UPGRADE
#<RuntimeError: RuntimeError>
/var/www/discourse/plugins/docker_manager/lib/docker_manager/upgrader.rb:203:in `run'
...

我曾以为也许可以执行 /var/discourse/launcher rebuild app,但结果也未能奏效,只是重新启动了相同的版本,但我确实注意到了以下输出:

$ ./launcher rebuild app
x86_64 arch detected.

WARNING: We are about to start downloading the Discourse base image
This process may take anywhere between a few minutes to an hour, depending on your network speed

Please be patient

2.0.20220818-0047: Pulling from discourse/base
1efc276f4ff9: Pull complete
1b880e64942b: Pull complete
794f6dc9a2ff: Pull complete
Digest: sha256:7734701087766821ffb2ddcef423754798bd345c2ac0d550131c6e6905c268e8
Status: Downloaded newer image for discourse/base:2.0.20220818-0047
docker.io/discourse/base:2.0.20220818-0047
...
I, [2022-09-13T02:09:12.828649 #1]  INFO -- : Replacing # redis with sv start redis || exit 1 in /etc/service/unicorn/run
I, [2022-09-13T02:09:12.829826 #1]  INFO -- : > cd /var/www/discourse/plugins && git clone https://github.com/discourse/docker_manager.git
Cloning into 'docker_manager'...
I, [2022-09-13T02:09:13.957219 #1]  INFO -- :
I, [2022-09-13T02:09:13.958187 #1]  INFO -- : > cd /var/www/discourse && git fetch --depth=1 origin tag v2.9.0.beta2 --no-tags
From https://github.com/discourse/discourse
 * [new tag]           v2.9.0.beta2 -> v2.9.0.beta2
I, [2022-09-13T02:09:18.214516 #1]  INFO -- :
I, [2022-09-13T02:09:18.215535 #1]  INFO -- : > cd /var/www/discourse && git checkout v2.9.0.beta2
Note: switching to 'v2.9.0.beta2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -
Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 88a85843 FIX: Cooking custom emojis should not use a secure URL (#15929)
I, [2022-09-13T02:09:19.557296 #1]  INFO -- :
...

我最终通过恢复备份撤销了这些更改,并认为我应该先在这里寻求一些建议,关于如何才能以及应该如何将 Discourse 正确地重新连接到 main 上的 HEAD 并开始使用最新的测试版进行构建——然后在我终于将它更新到最新版本后,我想在未来将其锁定到一个稳定的版本更新。我曾使用测试版来解决过去一年中遇到的问题,但这对我来说已经是一次足够的冒险了。:laughing:

您希望Discourse进行备份吗?您需要设法将容器内的postgres升级到pg14。如果现在返回PG 13还不算太晚,您会更满意。

您应该只执行命令行重建。

Hmm I have a couple thoughts @pfaffman:

  • 感谢您指出这一点。我太专注于更新 PGSQL 了,以至于忘记了需要迁移到 13 而不是 14。我觉得我要哭了!
  • 您见过有人成功地将数据库从 14 降级到 13 吗?
  • 理论上,我应该可以在服务器上为 13 添加另一个集群,这样 13 和 14 都可以运行,但我现在基本上已经确定使用 14 了,因为同一台服务器上还有其他几个服务也在运行,我实在无法再进一步调整它们了——所以我的唯一希望是安装一个 13 实例并降级 Discourse 的实例……
  • 我尝试了重建命令,但它就是不起作用。您是指我上面分享的内容,对吗?:/var/discourse/launcher rebuild app,

因此,输出包含一个“Note”,但这并非错误。每次检出非最新版本时,都应收到“detached head”消息。

1 个赞

我完全理解你的感受。

那不是我的专业领域。将容器更新为使用 pg14 工具要容易得多。只要你不想恢复到 pg13 站点,你就会没事的。

它怎么就不行了呢?如果这是在你的生产服务器上,你可能想先在测试服务器上进行此操作。