pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_restore 12 "permission denied for schema" errors
17+ messages / 4 participants
[nested] [flat]
* pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 00:58 Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Ron @ 2022-10-20 00:58 UTC (permalink / raw)
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
RDS Postgresql 12.11
Backed up a database from one RDS instance, and now am trying to restore it
to a new instance. (If you're wondering why, it's to restore in an instance
with less disk space.)
Here are the commands:
export PGHOST=${RDSENV}.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
cd /migrate/TASK001793786/2022-10-19b
DB=sides
pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
Attached are log file extracts showing the errors. The errors are only on
partitioned child tables, the list of which is also attached. However, some
(but not many)
Some of the erroring tables are owned by sides_owner and some are owned by
"stransuser".
"\z" on a child with errors looks exactly like a child without errors.
What could be the problem?
--
Angular momentum makes the world go 'round.
Attachments:
pg_restore errors 1.log (text/x-log, 4.1K) download
[a467197@uisawsclitstlinrds TASK001793786]$ grep -B3 ERROR: TASK001793786_restore.out | more
pg_restore: processing data for table "strans.response_xml_p2019_10"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 7699; 0 3661008 TABLE DATA response_xml_p2019_10 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2019_10": ERROR: permission denied for schema strans
--
QUERY: SELECT 1 FROM ONLY "strans"."employer_response" x WHERE "employer_response_id" OPERATOR(pg_catalog.=) $1 AND "part_date" OPERATOR(pg_catalog.=) $
2 FOR KEY SHARE OF x
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 7931; 0 3847065 TABLE DATA response_xml_p2022_01 stransuser
pg_restore: error: COPY failed for table "response_xml_p2022_01": ERROR: permission denied for schema strans
--
pg_restore: launching item 8045 TABLE DATA dd_request_attachment
pg_restore: processing data for table "strans.dd_request_attachment"
pg_restore: from TOC entry 7715; 0 3661104 TABLE DATA response_xml_p2021_02 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2021_02": ERROR: permission denied for schema strans
--
pg_restore: launching item 7692 TABLE DATA response_xml_p2019_03
pg_restore: processing data for table "strans.response_xml_p2019_03"
pg_restore: from TOC entry 7694; 0 3660978 TABLE DATA response_xml_p2019_05 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2019_05": ERROR: permission denied for schema strans
--
pg_restore: launching item 7687 TABLE DATA response_xml_p2018_10
pg_restore: processing data for table "strans.response_xml_p2018_10"
pg_restore: from TOC entry 7692; 0 3660966 TABLE DATA response_xml_p2019_03 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2019_03": ERROR: permission denied for schema strans
--
pg_restore: launching item 7998 TABLE DATA ev_request_xml
pg_restore: processing data for table "strans.ev_request_xml"
pg_restore: from TOC entry 7687; 0 3660936 TABLE DATA response_xml_p2018_10 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2018_10": ERROR: permission denied for schema strans
--
pg_restore: launching item 7688 TABLE DATA response_xml_p2018_11
pg_restore: processing data for table "strans.response_xml_p2018_11"
pg_restore: from TOC entry 7688; 0 3660942 TABLE DATA response_xml_p2018_11 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2018_11": ERROR: permission denied for schema strans
--
pg_restore: launching item 7429 FK CONSTRAINT employer_response response_to_request
pg_restore: creating FK CONSTRAINT "strans.employer_response response_to_request"
pg_restore: from TOC entry 7691; 0 3660960 TABLE DATA response_xml_p2019_02 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2019_02": ERROR: permission denied for schema strans
--
pg_restore: launching item 7725 TABLE DATA response_xml_p2021_12
pg_restore: processing data for table "strans.response_xml_p2021_12"
pg_restore: from TOC entry 7683; 0 3660543 TABLE DATA request_xml_p2021_10 sides_owner
pg_restore: error: COPY failed for table "request_xml_p2021_10": ERROR: permission denied for schema strans
--
pg_restore: launching item 7670 TABLE DATA request_xml_p2020_09
pg_restore: processing data for table "strans.request_xml_p2020_09"
pg_restore: from TOC entry 7725; 0 3661164 TABLE DATA response_xml_p2021_12 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2021_12": ERROR: permission denied for schema strans
--
pg_restore: launching item 7719 TABLE DATA response_xml_p2021_06
pg_restore: processing data for table "strans.response_xml_p2021_06"
pg_restore: from TOC entry 7670; 0 3660465 TABLE DATA request_xml_p2020_09 sides_owner
pg_restore: error: COPY failed for table "request_xml_p2020_09": ERROR: permission denied for schema strans
--
pg_restore: launching item 8031 TABLE DATA dd_report_extract
pg_restore: processing data for table "strans.dd_report_extract"
pg_restore: from TOC entry 7719; 0 3661128 TABLE DATA response_xml_p2021_06 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2021_06": ERROR: permission denied for schema strans
pg_restore errors 2.log (text/x-log, 1.6K) download
--
pg_restore: launching item 7657 TABLE DATA request_xml_p2019_08
pg_restore: processing data for table "strans.request_xml_p2019_08"
pg_restore: from TOC entry 7649; 0 3660339 TABLE DATA request_xml_p2018_12 sides_owner
pg_restore: error: COPY failed for table "request_xml_p2018_12": ERROR: permission denied for schema strans
--
pg_restore: launching item 8007 TABLE DATA ev_day
pg_restore: processing data for table "strans.ev_day"
pg_restore: from TOC entry 7657; 0 3660387 TABLE DATA request_xml_p2019_08 sides_owner
pg_restore: error: COPY failed for table "request_xml_p2019_08": ERROR: permission denied for schema strans
--
pg_restore: launching item 6582 INDEX xif2ev_day
pg_restore: creating INDEX "strans.xif2ev_day"
pg_restore: from TOC entry 7940; 0 3847173 TABLE DATA response_xml_p2022_10 stransuser
pg_restore: error: COPY failed for table "response_xml_p2022_10": ERROR: permission denied for schema strans
--
pg_restore: launching item 6736 INDEX xif1dd_request_response
pg_restore: creating INDEX "strans.xif1dd_request_response"
pg_restore: from TOC entry 7714; 0 3661098 TABLE DATA response_xml_p2021_01 sides_owner
pg_restore: error: COPY failed for table "response_xml_p2021_01": ERROR: permission denied for schema strans
--
pg_restore: launching item 7659 TABLE DATA request_xml_p2019_10
pg_restore: processing data for table "strans.request_xml_p2019_10"
pg_restore: from TOC entry 7659; 0 3660399 TABLE DATA request_xml_p2019_10 sides_owner
pg_restore: error: COPY failed for table "request_xml_p2019_10": ERROR: permission denied for schema strans
all partitioned tables.txt (text/plain, 9.8K) download
$ psql sides -c "\d" | grep " re[qs]" | grep table
strans | request_xml | partitioned table | sides_owner
strans | request_xml_p2018_10 | table | sides_owner
strans | request_xml_p2018_11 | table | sides_owner
strans | request_xml_p2018_12 | table | sides_owner
strans | request_xml_p2019_01 | table | sides_owner
strans | request_xml_p2019_02 | table | sides_owner
strans | request_xml_p2019_03 | table | sides_owner
strans | request_xml_p2019_04 | table | sides_owner
strans | request_xml_p2019_05 | table | sides_owner
strans | request_xml_p2019_06 | table | sides_owner
strans | request_xml_p2019_07 | table | sides_owner
strans | request_xml_p2019_08 | table | sides_owner
strans | request_xml_p2019_09 | table | sides_owner
strans | request_xml_p2019_10 | table | sides_owner
strans | request_xml_p2019_11 | table | sides_owner
strans | request_xml_p2019_12 | table | sides_owner
strans | request_xml_p2020_01 | table | sides_owner
strans | request_xml_p2020_02 | table | sides_owner
strans | request_xml_p2020_03 | table | sides_owner
strans | request_xml_p2020_04 | table | sides_owner
strans | request_xml_p2020_05 | table | sides_owner
strans | request_xml_p2020_06 | table | sides_owner
strans | request_xml_p2020_07 | table | sides_owner
strans | request_xml_p2020_08 | table | sides_owner
strans | request_xml_p2020_09 | table | sides_owner
strans | request_xml_p2020_10 | table | sides_owner
strans | request_xml_p2020_11 | table | sides_owner
strans | request_xml_p2020_12 | table | sides_owner
strans | request_xml_p2021_01 | table | sides_owner
strans | request_xml_p2021_02 | table | sides_owner
strans | request_xml_p2021_03 | table | sides_owner
strans | request_xml_p2021_04 | table | sides_owner
strans | request_xml_p2021_05 | table | sides_owner
strans | request_xml_p2021_06 | table | sides_owner
strans | request_xml_p2021_07 | table | sides_owner
strans | request_xml_p2021_08 | table | sides_owner
strans | request_xml_p2021_09 | table | sides_owner
strans | request_xml_p2021_10 | table | sides_owner
strans | request_xml_p2021_11 | table | sides_owner
strans | request_xml_p2021_12 | table | sides_owner
strans | request_xml_p2022_01 | table | stransuser
strans | request_xml_p2022_02 | table | stransuser
strans | request_xml_p2022_03 | table | stransuser
strans | request_xml_p2022_04 | table | stransuser
strans | request_xml_p2022_05 | table | stransuser
strans | request_xml_p2022_06 | table | stransuser
strans | request_xml_p2022_07 | table | stransuser
strans | request_xml_p2022_08 | table | stransuser
strans | request_xml_p2022_09 | table | stransuser
strans | request_xml_p2022_10 | table | stransuser
strans | request_xml_p2022_11 | table | stransuser
strans | request_xml_p2022_12 | table | stransuser
strans | request_xml_p2023_01 | table | sides_owner
strans | request_xml_p2023_02 | table | sides_owner
strans | request_xml_p2023_03 | table | sides_owner
strans | request_xml_p2023_04 | table | sides_owner
strans | request_xml_p2023_05 | table | sides_owner
strans | request_xml_p2023_06 | table | sides_owner
strans | request_xml_p2023_07 | table | sides_owner
strans | request_xml_p2023_08 | table | sides_owner
strans | request_xml_p2023_09 | table | sides_owner
strans | request_xml_p2023_10 | table | sides_owner
strans | request_xml_p2023_11 | table | sides_owner
strans | request_xml_p2023_12 | table | sides_owner
strans | request_xml_ple2018_09 | table | sides_owner
strans | response_attachment | table | sides_owner
strans | response_x_error | table | sides_owner
strans | response_xml | partitioned table | sides_owner
strans | response_xml_p2018_10 | table | sides_owner
strans | response_xml_p2018_11 | table | sides_owner
strans | response_xml_p2018_12 | table | sides_owner
strans | response_xml_p2019_01 | table | sides_owner
strans | response_xml_p2019_02 | table | sides_owner
strans | response_xml_p2019_03 | table | sides_owner
strans | response_xml_p2019_04 | table | sides_owner
strans | response_xml_p2019_05 | table | sides_owner
strans | response_xml_p2019_06 | table | sides_owner
strans | response_xml_p2019_07 | table | sides_owner
strans | response_xml_p2019_08 | table | sides_owner
strans | response_xml_p2019_09 | table | sides_owner
strans | response_xml_p2019_10 | table | sides_owner
strans | response_xml_p2019_11 | table | sides_owner
strans | response_xml_p2019_12 | table | sides_owner
strans | response_xml_p2020_01 | table | sides_owner
strans | response_xml_p2020_02 | table | sides_owner
strans | response_xml_p2020_03 | table | sides_owner
strans | response_xml_p2020_04 | table | sides_owner
strans | response_xml_p2020_05 | table | sides_owner
strans | response_xml_p2020_06 | table | sides_owner
strans | response_xml_p2020_07 | table | sides_owner
strans | response_xml_p2020_08 | table | sides_owner
strans | response_xml_p2020_09 | table | sides_owner
strans | response_xml_p2020_10 | table | sides_owner
strans | response_xml_p2020_11 | table | sides_owner
strans | response_xml_p2020_12 | table | sides_owner
strans | response_xml_p2021_01 | table | sides_owner
strans | response_xml_p2021_02 | table | sides_owner
strans | response_xml_p2021_03 | table | sides_owner
strans | response_xml_p2021_04 | table | sides_owner
strans | response_xml_p2021_05 | table | sides_owner
strans | response_xml_p2021_06 | table | sides_owner
strans | response_xml_p2021_07 | table | sides_owner
strans | response_xml_p2021_08 | table | sides_owner
strans | response_xml_p2021_09 | table | sides_owner
strans | response_xml_p2021_10 | table | sides_owner
strans | response_xml_p2021_11 | table | sides_owner
strans | response_xml_p2021_12 | table | sides_owner
strans | response_xml_p2022_01 | table | stransuser
strans | response_xml_p2022_02 | table | stransuser
strans | response_xml_p2022_03 | table | stransuser
strans | response_xml_p2022_04 | table | stransuser
strans | response_xml_p2022_05 | table | stransuser
strans | response_xml_p2022_06 | table | stransuser
strans | response_xml_p2022_07 | table | stransuser
strans | response_xml_p2022_08 | table | stransuser
strans | response_xml_p2022_09 | table | stransuser
strans | response_xml_p2022_10 | table | stransuser
strans | response_xml_p2022_11 | table | stransuser
strans | response_xml_p2022_12 | table | stransuser
strans | response_xml_p2023_01 | table | sides_owner
strans | response_xml_p2023_02 | table | sides_owner
strans | response_xml_p2023_03 | table | sides_owner
strans | response_xml_p2023_04 | table | sides_owner
strans | response_xml_p2023_05 | table | sides_owner
strans | response_xml_p2023_06 | table | sides_owner
strans | response_xml_p2023_07 | table | sides_owner
strans | response_xml_p2023_08 | table | sides_owner
strans | response_xml_p2023_09 | table | sides_owner
strans | response_xml_p2023_10 | table | sides_owner
strans | response_xml_p2023_11 | table | sides_owner
strans | response_xml_p2023_12 | table | sides_owner
strans | response_xml_ple2018_09 | table | sides_owner
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 05:03 Frank Gard <frank.von.postgresql.org@familie-gard.de>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Frank Gard @ 2022-10-20 05:03 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Hi Ron,
Am 20.10.22 um 02:58 schrieb Ron:
> RDS Postgresql 12.11
>
> Backed up a database from one RDS instance, and now am trying to restore it to a new instance. (If you're wondering why, it's to restore in an instance with less disk space.)
>
> Here are the commands:
>
> export PGHOST=${RDSENV}.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
> cd /migrate/TASK001793786/2022-10-19b
> DB=sides
> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
What database do you want to restore your data into? As far as I know your pg_restore command would import the data into template1, right? pg_restore's manpage says:
> […]
> -ddbname
> --dbname=dbname
> Connect to database dbnameand restore directly into the database. The dbnamecan be a connection string. If so, connection string parameters will override any conflicting command line options.
> […] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
And I'm wondering, if it's what you want. Possibly your errors could come from there…
Cheers,
Frank.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 05:12 Tom Lane <tgl@sss.pgh.pa.us>
parent: Frank Gard <frank.von.postgresql.org@familie-gard.de>
0 siblings, 2 replies; 17+ messages in thread
From: Tom Lane @ 2022-10-20 05:12 UTC (permalink / raw)
To: Frank Gard <frank.von.postgresql.org@familie-gard.de>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
Frank Gard <frank.von.postgresql.org@familie-gard.de> writes:
> Am 20.10.22 um 02:58 schrieb Ron:
>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
> What database do you want to restore your data into? As far as I know your pg_restore command would import the data into template1, right?
No --- my ears went up about that too, but he's using --create.
So template1 is just the springboard for the initial connection
in which CREATE DATABASE will be issued.
My guess is that there's something inconsistent between source
and target installations about roles and role-privilege grants.
We don't have enough details to do more than guess, though.
regards, tom lane
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 07:38 Frank Gard <frank.von.postgresql.org@familie-gard.de>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 17+ messages in thread
From: Frank Gard @ 2022-10-20 07:38 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi Tom,
Am 20.10.22 um 07:12 schrieb Tom Lane:
> Frank Gard<frank.von.postgresql.org@familie-gard.de> writes:
>> Am 20.10.22 um 02:58 schrieb Ron:
>>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
>> What database do you want to restore your data into? As far as I know your pg_restore command would import the data into template1, right?
> No --- my ears went up about that too, but he's using --create.
> So template1 is just the springboard for the initial connection
> in which CREATE DATABASE will be issued.
you're right, of course. Overseen that detail. I've to learn to read more carefully before answering. Sorry.
Frank.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 13:20 Ron <ronljohnsonjr@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 17+ messages in thread
From: Ron @ 2022-10-20 13:20 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 10/20/22 00:12, Tom Lane wrote:
> Frank Gard <frank.von.postgresql.org@familie-gard.de> writes:
>> Am 20.10.22 um 02:58 schrieb Ron:
>>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
>> What database do you want to restore your data into? As far as I know your pg_restore command would import the data into template1, right?
> No --- my ears went up about that too, but he's using --create.
> So template1 is just the springboard for the initial connection
> in which CREATE DATABASE will be issued.
>
> My guess is that there's something inconsistent between source
> and target installations about roles and role-privilege grants.
> We don't have enough details to do more than guess, though.
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.
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 15:02 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 2 replies; 17+ messages in thread
From: Adrian Klaver @ 2022-10-20 15:02 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
On 10/20/22 06:20, Ron wrote:
> On 10/20/22 00:12, Tom Lane wrote:
>> Frank Gard <frank.von.postgresql.org@familie-gard.de> writes:
>>> Am 20.10.22 um 02:58 schrieb Ron:
>>>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1
>>>> $DB
>>> What database do you want to restore your data into? As far as I know
>>> your pg_restore command would import the data into template1, right?
>> No --- my ears went up about that too, but he's using --create.
>> So template1 is just the springboard for the initial connection
>> in which CREATE DATABASE will be issued.
>>
>> My guess is that there's something inconsistent between source
>> and target installations about roles and role-privilege grants.
>> We don't have enough details to do more than guess, though.
>
> 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?
2) What does nproc --jobs=`nproc` resolve to?
3) What if you run without --jobs?
4) What user are you running the pg_restore as?
5) Why the --no-role-passwords in the pg_dump?
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 17:25 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 0 replies; 17+ messages in thread
From: Ron @ 2022-10-20 17:25 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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:
>>> Frank Gard <frank.von.postgresql.org@familie-gard.de> writes:
>>>> Am 20.10.22 um 02:58 schrieb Ron:
>>>>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
>>>> What database do you want to restore your data into? As far as I know
>>>> your pg_restore command would import the data into template1, right?
>>> No --- my ears went up about that too, but he's using --create.
>>> So template1 is just the springboard for the initial connection
>>> in which CREATE DATABASE will be issued.
>>>
>>> My guess is that there's something inconsistent between source
>>> and target installations about roles and role-privilege grants.
>>> We don't have enough details to do more than guess, though.
>>
>> 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?
The data is in an RDS Postgresql 12.11 instance.
pg_dump on the "client" Linux VM is v12.12 or 12.11 from RHEL8 packages.
(Don't remember the exact version ATM.)
> 2) What does nproc --jobs=`nproc` resolve to?
Two CPUs on the VM.
> 3) What if you run without --jobs?
I can test that, but will be under serious time constraints during the
maintenance window. Heavily parallel dump and restore are imperative.
> 4) What user are you running the pg_restore as?
PGUSER=postgres
> 5) Why the --no-role-passwords in the pg_dump?
That's a requirement for AWS RDS. User postgres does not have privs to dump
the password hash from pg_authid.
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-20 21:34 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 2 replies; 17+ messages in thread
From: Ron @ 2022-10-20 21:34 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
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:
>>> Frank Gard <frank.von.postgresql.org@familie-gard.de> writes:
>>>> Am 20.10.22 um 02:58 schrieb Ron:
>>>>> pg_restore -v --create --clean --jobs=`nproc` -Fd --dbname=template1 $DB
>>>> What database do you want to restore your data into? As far as I know
>>>> your pg_restore command would import the data into template1, right?
>>> No --- my ears went up about that too, but he's using --create.
>>> So template1 is just the springboard for the initial connection
>>> in which CREATE DATABASE will be issued.
>>>
>>> My guess is that there's something inconsistent between source
>>> and target installations about roles and role-privilege grants.
>>> We don't have enough details to do more than guess, though.
>>
>> 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.
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 16:20 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ron <ronljohnsonjr@gmail.com>
1 sibling, 1 reply; 17+ messages in thread
From: Adrian Klaver @ 2022-10-22 16:20 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
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.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 16:41 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 17+ messages in thread
From: Ron @ 2022-10-22 16:41 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 17:00 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Adrian Klaver @ 2022-10-22 17:00 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
On 10/22/22 09:41, Ron wrote:
> 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 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
The above and below have me confused.
What is $NEWDB?
In above it seems to be a file and below a database name.
> 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.
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 21:02 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 17+ messages in thread
From: Ron @ 2022-10-22 21:02 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 10/22/22 12:00, Adrian Klaver wrote:
> On 10/22/22 09:41, Ron wrote:
>> 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 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
>
> The above and below have me confused.
>
> What is $NEWDB?
>
> In above it seems to be a file and below a database name.
Consider it pseudo-code.
>
>> 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.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 21:29 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Adrian Klaver @ 2022-10-22 21:29 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
On 10/22/22 14:02, Ron wrote:
> On 10/22/22 12:00, Adrian Klaver wrote:
>> On 10/22/22 09:41, Ron wrote:
>>> 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 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
>>
>> The above and below have me confused.
>>
>> What is $NEWDB?
>>
>> In above it seems to be a file and below a database name.
>
> Consider it pseudo-code.
To pseudo for me.
What file exactly is:
pg_restore --jobs=X --no-owner $NEWDB
restoring?
And how was that file created?
Knowing this might help get at why the more straight forward method does
not work.
>
>>
>>> 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.
>>>
>>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 21:45 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 17+ messages in thread
From: Ron @ 2022-10-22 21:45 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 10/22/22 16:29, Adrian Klaver wrote:
> On 10/22/22 14:02, Ron wrote:
>> On 10/22/22 12:00, Adrian Klaver wrote:
>>> On 10/22/22 09:41, Ron wrote:
>>>> 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 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
>>>
>>> The above and below have me confused.
>>>
>>> What is $NEWDB?
>>>
>>> In above it seems to be a file and below a database name.
>>
>> Consider it pseudo-code.
>
> To pseudo for me.
>
> What file exactly is:
>
> pg_restore --jobs=X --no-owner $NEWDB
>
> restoring?
>
> And how was that file created?
>
> Knowing this might help get at why the more straight forward method does
> not work.
This is what I ran to restore the database:
export PGHOST=${RDSENV}.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
cd /migrate/TASK001793786/2022-10-19b
NEWDB=sides
pg_restore -v --create --clean --no-owner --jobs=`nproc` -Fd
--dbname=template1 $NEWDB
psql $NEWDB -f all_OWNER.sql
psql $NEWDB -f all_GRANT.sql
The name of the database is "sides", and there's a directorynamed "sides"
under /migrate/TASK001793786/2022-10-19b.
>>
>>>
>>>> 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.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-22 22:06 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Adrian Klaver @ 2022-10-22 22:06 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
On 10/22/22 14:45, Ron wrote:
> On 10/22/22 16:29, Adrian Klaver wrote:
>> To pseudo for me.
>>
>> What file exactly is:
>>
>> pg_restore --jobs=X --no-owner $NEWDB
>>
>> restoring?
>>
>> And how was that file created?
>>
>> Knowing this might help get at why the more straight forward method
>> does not work.
>
> This is what I ran to restore the database:
> export PGHOST=${RDSENV}.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
> cd /migrate/TASK001793786/2022-10-19b
> NEWDB=sides
> pg_restore -v --create --clean --no-owner --jobs=`nproc` -Fd
> --dbname=template1 $NEWDB
> psql $NEWDB -f all_OWNER.sql
> psql $NEWDB -f all_GRANT.sql
>
> The name of the database is "sides", and there's a directorynamed
> "sides" under /migrate/TASK001793786/2022-10-19b.
Aah, I forgot about the -Fd, now it makes more sense.
To get past the --jobs induced error required the addition of --no-owner
and then adding owners and grants after the main restore.
What was the pg_dump command that produced
/migrate/TASK001793786/2022-10-19b/sides ?
>
>>>
>>>>
>>>>> 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.
>>>>>
>>>>
>>>
>>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-23 04:23 Ron <ronljohnsonjr@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 17+ messages in thread
From: Ron @ 2022-10-23 04:23 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 10/22/22 17:06, Adrian Klaver wrote:
> On 10/22/22 14:45, Ron wrote:
>> On 10/22/22 16:29, Adrian Klaver wrote:
>
>>> To pseudo for me.
>>>
>>> What file exactly is:
>>>
>>> pg_restore --jobs=X --no-owner $NEWDB
>>>
>>> restoring?
>>>
>>> And how was that file created?
>>>
>>> Knowing this might help get at why the more straight forward method does
>>> not work.
>>
>> This is what I ran to restore the database:
>> export PGHOST=${RDSENV}.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
>> cd /migrate/TASK001793786/2022-10-19b
>> NEWDB=sides
>> pg_restore -v --create --clean --no-owner --jobs=`nproc` -Fd
>> --dbname=template1 $NEWDB
>> psql $NEWDB -f all_OWNER.sql
>> psql $NEWDB -f all_GRANT.sql
>>
>> The name of the database is "sides", and there's a directorynamed "sides"
>> under /migrate/TASK001793786/2022-10-19b.
>
> Aah, I forgot about the -Fd, now it makes more sense.
>
> To get past the --jobs induced error required the addition of --no-owner
> and then adding owners and grants after the main restore.
>
> What was the pg_dump command that produced
> /migrate/TASK001793786/2022-10-19b/sides ?
PGHOST=mumble.xxxxxxxxxxxx.us-east-1.rds.amazonaws.com
PGUSER=postgres
cd /migrate/TASK001793786/`date +%F`
DB=sides
pg_dump -d $DB -j4 -Z0 -v -Fd --file=$DB 2> ${DB}_pgdump.log
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 17+ messages in thread
* Re: pg_restore 12 "permission denied for schema" errors
@ 2022-10-23 04:36 Tom Lane <tgl@sss.pgh.pa.us>
parent: Ron <ronljohnsonjr@gmail.com>
1 sibling, 0 replies; 17+ messages in thread
From: Tom Lane @ 2022-10-23 04:36 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
Ron <ronljohnsonjr@gmail.com> writes:
> On 10/20/22 10:02, Adrian Klaver wrote:
>> 3) What if you run without --jobs?
> It runs without error. Add "--jobs=2" and the errors appear.
That's ... suggestive ... but not suggestive enough. Can you
create a self-contained test case? It probably doesn't depend
much at all on your data, just the schema.
regards, tom lane
^ permalink raw reply [nested|flat] 17+ messages in thread
end of thread, other threads:[~2022-10-23 04:36 UTC | newest]
Thread overview: 17+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 00:58 pg_restore 12 "permission denied for schema" errors Ron <ronljohnsonjr@gmail.com>
2022-10-20 05:03 ` Frank Gard <frank.von.postgresql.org@familie-gard.de>
2022-10-20 05:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-10-20 07:38 ` Frank Gard <frank.von.postgresql.org@familie-gard.de>
2022-10-20 13:20 ` Ron <ronljohnsonjr@gmail.com>
2022-10-20 15:02 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-20 17:25 ` Ron <ronljohnsonjr@gmail.com>
2022-10-20 21:34 ` Ron <ronljohnsonjr@gmail.com>
2022-10-22 16:20 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-22 16:41 ` Ron <ronljohnsonjr@gmail.com>
2022-10-22 17:00 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-22 21:02 ` Ron <ronljohnsonjr@gmail.com>
2022-10-22 21:29 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-22 21:45 ` Ron <ronljohnsonjr@gmail.com>
2022-10-22 22:06 ` Adrian Klaver <adrian.klaver@aklaver.com>
2022-10-23 04:23 ` Ron <ronljohnsonjr@gmail.com>
2022-10-23 04:36 ` Tom Lane <tgl@sss.pgh.pa.us>
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