更新后,网站无法打开,并且备份数据库未加载

我更新了网站,然后它开始出现 nginx 错误。我无法访问该网站。无论我做什么,它都无法正常工作。所以我重新安装了一个新版本,并尝试添加昨天的食物。但是,我也没能成功。恢复备份时,我收到以下错误:

error complete:

CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE INDEX
ERROR:  unrecognized parameter "dims"
EXCEPTION: psql failed: ERROR:  unrecognized parameter "dims"
/var/www/discourse/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:51:in `run'
script/discourse:149:in `restore'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
script/discourse:290:in `<top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.2.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/var/www/discourse/tmp/restores/default/2024-02-18-120937' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

更新用于构建 pgembeddings 代码的 app.yml 时:

hooks:
  after_code:
    - exec:
        cd: $home
        cmd:
          - sudo apt-get install wget ca-certificates
    - exec:
        cd: $home
        cmd:
          - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
    - exec:
        cd: $home
        cmd:
          - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
    - exec:
        cd: $home
        cmd:
          - apt-get update
    - exec:
        cd: $home
        cmd:
          - apt-get -y install -y postgresql-server-dev-${PG_MAJOR}
    - exec:
        cd: $home/tmp
        cmd:
          - git clone https://github.com/neondatabase/pg_embedding.git
    - exec:
        cd: $home/tmp/pg_embedding
        cmd:
          - make PG_CONFIG=/usr/lib/postgresql/13/bin/pg_config
    - exec:
        cd: $home/tmp/pg_embedding
        cmd:
          - make PG_CONFIG=/usr/lib/postgresql/13/bin/pg_config install
    - exec:
        cd: $home
        cmd:
          - su postgres -c 'psql discourse -c "create extension if not exists embedding;"'
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-question-answer.git
          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-gamification.git
          - git clone https://github.com/discourse/discourse-restricted-replies.git
          - git clone https://github.com/discourse/discourse-saved-searches.git
          - git clone https://github.com/discourse/discourse-follow.git
          - git clone https://github.com/discourse/discourse-yearly-review.git
          - git clone https://github.com/discourse/discourse-voting.git
          - git clone https://github.com/discourse/discourse-no-bump.git
          - git clone https://github.com/discourse/discourse-math.git
          - git clone https://github.com/discourse/discourse-akismet.git
          - git clone https://github.com/discourse/discourse-adplugin.git
          - git clone https://github.com/spirobel/discourse-matheditor.git
          - git clone https://github.com/discourse/discourse-google-one-tap.git
          - git clone https://github.com/merefield/discourse-chatbot.git
          - git clone https://github.com/discourse/discourse-ai.git
#          - git clone https://github.com/paviliondev/discourse-custom-wizard.git
          - git clone https://github.com/discourse/discourse-reactions.git
#          - git clone https://github.com/discourse/discourse-subscriptions.git

我已经和 @kuaza 一起查看了这个问题,因为他以前处理过我的插件。

我们从 dump.sql 中删除了导致上述错误的索引,然后又恢复了它。

有一个更新的脚本可以删除这个索引,但插件的一些用户可能没有看到更新。

我们现在有一个构建,但浏览器没有连接。

我们已经重新启动了容器,删除了有问题的索引,并且移除了 app.yml 中用于构建 pgembedding 的所有旧脚本,所以它现在是干净的,但带有插件。

容器已启动 - 您可以正常进入。

psql 似乎已启动 - 您可以正常在容器内启动数据库提示符。

在容器内,您可以正常打开 rails c。

/var/discourse/shared/standalone/log/rails# tail -n 200 production.log

没有显示任何明显的错误消息。

我现在很困惑。

有什么其他可以检查的建议吗?

1 个赞

我错过了一个检查……

进入容器并执行此操作:

curl 0.0.0.0:3000

接下来我将尝试这个……

2 个赞

执行此操作时,会显示设置 HTML 页面的代码。我认为问题是由 DNS 引起的。这种胡闹快把我逼疯了。

运行此命令时,它似乎在工作,但实际上问题在于 Web 服务器未正常运行,我们无法以此方式理解。当我们进入容器并运行此代码时,我们可以看到 nginx 是否正在运行:

nginx -t

但是,我想通过复制您消息中的解决方案来回答此主题中的问题。nginx 问题完全不同,我正在一个具有全新安装的独立域上进行测试。如果再次出现错误,我将打开一个单独的问题并进行报告。

主题中备份无法工作的根本原因是某个不再使用的表或记录。我认为这是聊天机器人插件不再使用的记录,但在更新过程中并未删除。我认为插件作者朋友已经解决了这个问题,您可以放心 :slight_smile: 我删除了错误行,重新打包并从管理员面板安装,它运行正常。或者您也可以从服务器下载:

解释如何修复损坏的插件文件:

  • 解压备份:tar -xvzf foo.tar.gz
  • 解压 dump.sql 文件
  • 删除构建不需要索引的错误行:
--
-- TOC entry 8020 (class 1259 OID 84313)
-- Name: hnsw_index_on_chatbot_post_embeddings; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX hnsw_index_on_chatbot_post_embeddings ON public.chatbot_post_embeddings_old USING hnsw (embedding) WITH (dims='1536', m='64', efconstruction='64', efsearch='64');
  • 重新压缩 dump.sql 文件
  • 将其与您的 uploads 文件夹放在同一个目录中
  • 将整个内容重新打包
  • 手动恢复此文件

如果出现不同表的错误,我认为通过上述方法删除包含该记录的表即可解决。

我辛辛苦苦建立并开始发展的网站停运了两天。别忘了还有不眠之夜和白天。我们总有可能发生此类事件。不要忘记进行备份并检查备份是否正常工作。我想感谢我的兄弟 @merefield 在此过程中帮助了我。我们一起学到了新东西。

3 个赞

此方法在我遇到相同错误时对我有用。感谢您发布此信息。

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.