Thread: BUG #18115: pg_restore of extensions does not respect dependencies

BUG #18115: pg_restore of extensions does not respect dependencies

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      18115
Logged by:          Vasileios Giannakidis
Email address:      vasilgiann@gmail.com
PostgreSQL version: 14.7
Operating system:   Red Hat 7.3.1-6 64-bit
Description:

I have an issue that takes place during restore of a 14.4 database. During
this process creation of extension aws_s3 fails because it depends on
plpgsql extension which it seems to be created later on.  These are the
commands we use for dump / restore:

pg_dump -d \$DATABASE_URL -j 8 -Z 0 -Fd -f ${backupDir}
pg_restore --verbose --clean --no-owner -d \$DATABASE_URL -j 8 --format=d
${backupDir}

This is the output of the pg_restore:
[2023-09-15T14:31:48.653Z] pg_restore: processing item 2 EXTENSION aws_s3
[2023-09-15T14:31:48.653Z] pg_restore: creating EXTENSION "aws_s3"
[2023-09-15T14:31:48.653Z] pg_restore: from TOC entry 2; 3079 57504364
EXTENSION aws_s3 (no owner)
[2023-09-15T14:31:48.653Z] pg_restore: error: could not execute query:
ERROR:  language "plpgsql" does not exist
[2023-09-15T14:31:48.653Z] HINT:  Use CREATE EXTENSION to load the language
into the database.
[2023-09-15T14:31:48.653Z] Command was: CREATE EXTENSION IF NOT EXISTS
aws_s3 WITH SCHEMA extensions;
[2023-09-15T14:31:48.653Z] 
[2023-09-15T14:31:48.653Z] 
[2023-09-15T14:31:48.653Z] pg_restore: processing item 8536 COMMENT
EXTENSION aws_s3
[2023-09-15T14:31:48.653Z] pg_restore: creating COMMENT "EXTENSION aws_s3"
[2023-09-15T14:31:48.653Z] pg_restore: from TOC entry 8536; 0 0 COMMENT
EXTENSION aws_s3 
[2023-09-15T14:31:48.653Z] pg_restore: error: could not execute query:
ERROR:  extension "aws_s3" does not exist
[2023-09-15T14:31:48.653Z] Command was: COMMENT ON EXTENSION aws_s3 IS 'AWS
S3 extension for importing data from S3';
[2023-09-15T14:31:48.653Z] 
[2023-09-15T14:31:48.653Z] 
[2023-09-15T14:31:48.653Z] pg_restore: processing item 194 SCHEMA
extensions
[2023-09-15T14:31:48.653Z] pg_restore: creating SCHEMA "extensions"
[2023-09-15T14:31:48.653Z] pg_restore: processing item 1 EXTENSION plpgsql
[2023-09-15T14:31:48.653Z] pg_restore: creating EXTENSION "plpgsql"
[2023-09-15T14:31:48.653Z] pg_restore: processing item 8539 COMMENT
EXTENSION plpgsql
[2023-09-15T14:31:48.653Z] pg_restore: creating COMMENT "EXTENSION
plpgsql"

It seems that dependencies between extensions are not considered by pg_dump.


Re: BUG #18115: pg_restore of extensions does not respect dependencies

From
Tom Lane
Date:
PG Bug reporting form <noreply@postgresql.org> writes:
> I have an issue that takes place during restore of a 14.4 database. During
> this process creation of extension aws_s3 fails because it depends on
> plpgsql extension which it seems to be created later on.

I don't know anything about aws_s3, but the only inter-extension
dependencies that are tracked by PG are those that are declared
in the extension control files (via "requires" entries).
Sounds to me like aws_s3 has failed to declare its dependency
on plpgsql.

            regards, tom lane



Re: BUG #18115: pg_restore of extensions does not respect dependencies

From
Michael Paquier
Date:
On Mon, Sep 18, 2023 at 09:58:56AM -0400, Tom Lane wrote:
> I don't know anything about aws_s3, but the only inter-extension
> dependencies that are tracked by PG are those that are declared
> in the extension control files (via "requires" entries).
> Sounds to me like aws_s3 has failed to declare its dependency
> on plpgsql.

This is something specific to RDS per the AWS docs:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PostgreSQL.S3Import.html

So, yes, that's something to take to them to make sure that the
dependency ordering is correctly tracked, I guess.
--
Michael

Attachment