Discourse 升级问题

您好,

我正在将 Discourse 从 v2.3.0.beta8 +212 升级到 2.4.0.beta1。

首先,我通过 Web UI 升级了 Docker 管理器。随后,Web UI 提示我需要在命令行中进行升级,于是我便照做了。

在升级过程中,我反复遇到错误。我执行了以下命令:

cd /var/discourse
su ./launcher rebuild app

该命令运行几分钟后,在数据库升级步骤失败。我重启了服务器,Discourse 恢复运行(但未完成升级),然后再次尝试升级,结果仍是相同的错误。

对于接下来的操作,您有什么建议吗?

以下是我运行 rebuild 时最后出现的几行日志:

Optimizing site icons...
I, [2019-07-09T01:22:18.589503 #13]  INFO -- : Terminating async processes
I, [2019-07-09T01:22:18.589624 #13]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/10/bin/postmaster -D /etc/postgresql/10/main pid: 67
I, [2019-07-09T01:22:18.589816 #13]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 183
2019-07-09 01:22:18.589 UTC [67] LOG:  received fast shutdown request
183:signal-handler (1562635338) Received SIGTERM scheduling shutdown...
2019-07-09 01:22:18.593 UTC [67] LOG:  aborting any active transactions
2019-07-09 01:22:18.599 UTC [67] LOG:  worker process: logical replication launcher (PID 76) exited with exit code 1
2019-07-09 01:22:18.599 UTC [71] LOG:  shutting down
2019-07-09 01:22:18.629 UTC [67] LOG:  database system is shut down
183:M 09 Jul 2019 01:22:18.645 # User requested shutdown...
183:M 09 Jul 2019 01:22:18.645 * Saving the final RDB snapshot before exiting.
183:M 09 Jul 2019 01:22:18.672 * DB saved on disk
183:M 09 Jul 2019 01:22:18.672 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 366 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
cbaaf74d12f5c22faf7f054d391f3570b5e7d8dd3b8bce421c57ef17c4b43c55
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

编辑:完整日志中唯一的错误是以下这些:

I, [2019-07-09T01:21:35.162142 #13]  INFO -- : > su postgres -c 'createdb discourse' || true
2019-07-09 01:21:35.330 UTC [80] postgres@postgres ERROR:  database "discourse" already exists
2019-07-09 01:21:35.330 UTC [80] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: database creation failed: ERROR:  database "discourse" already exists
I, [2019-07-09T01:21:35.332706 #13]  INFO -- :
I, [2019-07-09T01:21:35.333101 #13]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2019-07-09 01:21:35.444 UTC [91] postgres@discourse ERROR:  role "discourse" already exists
2019-07-09 01:21:35.444 UTC [91] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists

我注意到它在“Optimizing Site Icons…”之后便退出了——也许这里存在问题?

您可以尝试搜索“error role discourse already exists”

用该术语搜索后,没有找到任何有帮助的内容。

  • 一些帖子提到了插件,我已在 app.yml 中禁用了插件
  • 收到关于 Docker 版本过时的提示,已将其升级
  • 运行了 discourse doctor

错误依旧。

附上了启动重建的输出结果。

对于下一步该怎么做,有什么建议吗?

rebuild script.txt|附件 (140.9 KB)

值得注意的是,我的 app.xml 中设置了相对 URL 根路径。这是否可能导致升级出现问题?

env:
  DISCOURSE_RELATIVE_URL_ROOT: /epicenter/support

run:
  - exec: echo "开始执行自定义命令"

  - exec:
        cd: $home
        cmd:
          - mkdir -p public/epicenter/support
          - cd public/epicenter/support && ln -s ../../uploads && ln -s ../../backups
          - rm public/uploads
          - rm public/backups
  - replace:
       global: true
       filename: /etc/nginx/conf.d/discourse.conf
       from: proxy_pass http://discourse;
       to: |
          rewrite ^/(.*)$ /epicenter/support/$1 break;
          proxy_pass http://discourse;
  - replace:
       filename: /etc/nginx/conf.d/discourse.conf
       from: etag off;
       to: |
          etag off;
          location /epicenter/support {
             rewrite ^/epicenter/support/?(.*)$ /$1;
          }
  - replace:
         filename: /etc/nginx/conf.d/discourse.conf
         from: $proxy_add_x_forwarded_for
         to: $http_fastly_client_ip
         global: true

终于在我的第三或第四个工作会话中解决了这个问题。问题似乎是“uploads”文件夹中缺少图片。解决方案是进行全新安装,使用相同的“app.yml”文件,并用占位文件恢复缺失的图片备份。

在解决原始问题的同时,我注意到在之前的升级后,各种图标和图片消失了。当我尝试重建时,日志显示进程在“优化站点图片”后停止了。我认为它可能卡在某个缺失的图片上,并在未记录该特定错误的情况下退出了。(没有任何迹象表明问题是缺失的图片,也没有说明哪些图片文件缺失)。

最后,我用最新版本进行了全新的 Discourse 安装。我按照这里的说明从备份中恢复。我尝试了三次才成功。

首先,备份脚本因找不到上传文件而报错,于是我从之前的备份文件中复制了“uploads/default”文件夹。

我再次运行恢复脚本。这次它报错说找不到某个特定的图片文件。我创建了一个假图片文件,将其命名为相同的文件名,并放在指定的位置。

第三次运行恢复脚本。成功了!我的网站已从备份恢复,并更新到了最新版本。