还原时遇到问题:“无效命令 \restrict”

我无法从“Discourse 3.5.0.beta9-dev - 04dbc622ab1e0197d16703ba47cf005ec93697ee”恢复到当前版本(6f06709643fa5e2253606c46f79d089ca3393ac9)

[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /home/pfaffman/src/discourse-repos/discourse/tmp/restores/default/2025-10-28-201139 exists...
Downloading archive to tmp directory...
Extracting dump file...
Validating metadata...
  Current version: 20251024020353
  Restored version: 20250724012518
Enabling readonly mode...
Pausing sidekiq...
Waiting up to 60 seconds for Sidekiq to finish running jobs...
Creating missing functions in the discourse_functions schema...
Restoring dump file... (this may take a while)
invalid command \restrict
EXCEPTION: psql failed: invalid command \restrict

如果我从 database_restorer 中删除这些 printf 命令,它就可以工作:

      <<~CMD
        (
          printf '%s\n' "\restrict #{nonce}"
          #{sed_command}
          printf '%s\n' "\unrestrict #{nonce}"
        ) | #{self.class.psql_command} 2>&1
      CMD

看起来像是这个提交。

在我进行备份的版本(一个 cdck docker 容器)中,我有这个:

PostgreSQL 15.13 (Debian 15.13-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

而这是我尝试恢复的地方(在本地运行 pg15 的开发站点):

PostgreSQL 15.13 (Ubuntu 15.13-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit

我不明白这段代码试图做什么,所以我很困惑。

您需要使用 PG 15.14 版本,并确保您的所有实例都已更新到该版本。此更新修复了一个重大的安全问题。

3 个赞

啊。这是一个非常简单的解释。

谢谢。我会着手处理的。

2 个赞