pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_restore 12 "permission denied for schema" errors
Date: Sat, 22 Oct 2022 11:41:31 -0500
Message-ID: <119d108c-0669-a15d-2afe-3c4116130118@gmail.com> (raw)
In-Reply-To: <727e6a26-4b58-0aea-a701-9671b8935410@aklaver.com>
References: <287717df-88e2-a4a5-2025-260c39662bca@gmail.com>
	<40fd91d2-d981-2f44-4d58-a3f08a9448fb@familie-gard.de>
	<2980993.1666242738@sss.pgh.pa.us>
	<d073e1ec-86f4-19c7-206e-c76ad9792bdc@gmail.com>
	<ef3ae37b-cab0-7929-e695-e9711685766e@aklaver.com>
	<612cf1c4-1f2d-f068-d6cf-54b98bbeb646@gmail.com>
	<727e6a26-4b58-0aea-a701-9671b8935410@aklaver.com>

On 10/22/22 11:20, Adrian Klaver wrote:
> On 10/20/22 14:34, Ron wrote:
>> On 10/20/22 10:02, Adrian Klaver wrote:
>>> On 10/20/22 06:20, Ron wrote:
>>>> On 10/20/22 00:12, Tom Lane wrote:
>
>>>> I ran "pg_dumpall --globals-only --no-role-passwords" on the source 
>>>> instance, and applied it to the new instance before doing the 
>>>> pg_restore. If I hadn't done that, pg_restore would have thrown errors 
>>>> on all the GRANT and ALTER TABLE ... OWNER TO statements embedded in 
>>>> the backup.
>>>>
>>>
>>> Some questions:
>>>
>>> 1) The backup was from a Postgres 12.x database using a version 12 or 
>>> higher instance of pg_backup?
>>
>> pg_dump and pg_restore are 12.11 from RHEL8.
>>
>>> 3) What if you run without --jobs?
>>
>> It runs without error.  Add "--jobs=2" and the errors appear.
>>
>
> Hmm, that is beyond me.
>
> 1) I did notice that the pg_restore errors all where; ERROR: permission 
> denied for schema strans
>
> 2) They all occurred during CREATE INDEX or COPY, which would be the part 
> where --jobs kicks in.
>
> To me it looks like  out of order execution where the jobs starting on 
> their tasks before the main task got done granting permissions. I just 
> have no idea how that could happen.

I was afraid you were going to say that.

The work-around is to:
pg_dump $SRCDB --schema-only | grep -e '^\(GRANT|REVOKE\)' > all_GRANT.sql
pg_dump $SRCDB --schema-only | grep OWNER > all_OWNER.sql
pg_restore --jobs=X --no-owner $NEWDB
psql $NEWDB -f all_OWNER.sql
psql $NEWDB -f all_GRANT.sql

This is, of course, why we need to test the backup/restore process.

-- 
Angular momentum makes the world go 'round.





view thread (17+ messages)  latest in thread

Message-ID: <119d108c-0669-a15d-2afe-3c4116130118@gmail.com>
Permalink:  ../119d108c-0669-a15d-2afe-3c4116130118@gmail.com/
Also on:    postgresql.org/message-id/119d108c-0669-a15d-2afe-3c4116130118@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: pg_restore 12 "permission denied for schema" errors
  In-Reply-To: <119d108c-0669-a15d-2afe-3c4116130118@gmail.com>
  References: <287717df-88e2-a4a5-2025-260c39662bca@gmail.com> <40fd91d2-d981-2f44-4d58-a3f08a9448fb@familie-gard.de> <2980993.1666242738@sss.pgh.pa.us> <d073e1ec-86f4-19c7-206e-c76ad9792bdc@gmail.com> <ef3ae37b-cab0-7929-e695-e9711685766e@aklaver.com> <612cf1c4-1f2d-f068-d6cf-54b98bbeb646@gmail.com> <727e6a26-4b58-0aea-a701-9671b8935410@aklaver.com> <119d108c-0669-a15d-2afe-3c4116130118@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox