Trouble with restore: "invalid command \restrict"

I’m having trouble doing a restore from “Discourse 3.5.0.beta9-dev - 04dbc622ab1e0197d16703ba47cf005ec93697ee” to current (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

If I remove these printf commands from database_restorer, it works:

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

It looks like this commit.

On the version where the backup was made (a cdck docker container) I have this :

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

and this is where I’m trying to restore (dev site running pg15 on the bare metal):

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

I don’t understand what this code is trying to do, so I’m just confused.

You need to be on PG 15.14 and you need to make sure all your instances are on that. This patches a large security issue.

2 Likes

Aha. That’s a very simple explanation.

Thanks. I’ll get on that.