Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omHZ6-0005Rd-HR for pgsql-general@arkaria.postgresql.org; Sat, 22 Oct 2022 16:41:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1omHZ4-0000J6-Fd for pgsql-general@arkaria.postgresql.org; Sat, 22 Oct 2022 16:41:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omHZ4-0000Ij-2b for pgsql-general@lists.postgresql.org; Sat, 22 Oct 2022 16:41:38 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1omHZ0-00016h-Sc for pgsql-general@lists.postgresql.org; Sat, 22 Oct 2022 16:41:37 +0000 Received: by mail-oi1-x22a.google.com with SMTP id w196so6587051oiw.8 for ; Sat, 22 Oct 2022 09:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FKyg7/zKrnhRovjHY33QOTfMcXooe33LttU0A2mS0XQ=; b=B88PQxFq6XviFkjcU2LzlaAHSFppWgm3mysnjy0PvqoeD5ZHCa+lvL5tTsKlh4y0Dr KD/PUkBtVh7bRrD9JIqAVkIW9nha9F3mP+MER+u1FIiBPg7XJvZJS+Wz4wKpcMFrJogU hdphtEt2c7c514buWDtZHV6QdjHpyX6s2Ki/YjsA8WrPdvY9tkefPkaWmdj6+p9+1WdA Yl9nEyxFKzfvqAFOzeJUcMsOUxezFGYCDZ2ZXcGISmVmQYHMi5Jk2gXJDa7Trp6duAKk 54gVNBf16REwasn6BmKK8GC3FW5VvLFrkZc6AD3/BqJ5DbEirkJPgrjVpIR1x+B6S+or qtQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FKyg7/zKrnhRovjHY33QOTfMcXooe33LttU0A2mS0XQ=; b=Vogw1oHstNDICsNZRdwb80VtfFx/gRKIlNLHAI496nI7kWxBmJ47ENdRxQ31YloIlP ccOVpKqvs7I9AOWnykRZEE0kFjIRv7+dF6A1H3NIjdZp8dVIaoWWteDbB2xr4aNi6V1G YKFvLW0kEwrqqyhaExQiDW4Chm5dd31T3gVO6txttZJMj3uP+9bSEzctw/qwPHpUMMEQ DFKnP/7iLFmskDO46OmSEYDLupSO2za4EJVmlLZbxv7UY5nN4Q1+VEncnJkwAzybSzAI xcL+qT/W/Z1FhxF10zdfLqg9WsCoIyiRSs50We/F4AIyeSy2NAAdE+YL2i7nm8AUWr27 BpMA== X-Gm-Message-State: ACrzQf1tqSHoCZtLmYW3/7luYSE2ZPqH5QOnT+e+KoHOoDs0rmku7Cog mdrR8skaaADMh6KI/xeu/eJAx2ITOl0= X-Google-Smtp-Source: AMsMyM7wqILJaq6FgJ4CuFHY8yqUW4tTSio4ciPRYfqUIQd6EGqmYXOE75be3m0yxK8fWMhyWZx8oA== X-Received: by 2002:a05:6808:bd1:b0:355:362d:fcfb with SMTP id o17-20020a0568080bd100b00355362dfcfbmr12535167oik.15.1666456892503; Sat, 22 Oct 2022 09:41:32 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id g20-20020a056870c15400b0012796e8033dsm408360oad.57.2022.10.22.09.41.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 22 Oct 2022 09:41:31 -0700 (PDT) Message-ID: <119d108c-0669-a15d-2afe-3c4116130118@gmail.com> Date: Sat, 22 Oct 2022 11:41:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: pg_restore 12 "permission denied for schema" errors Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <287717df-88e2-a4a5-2025-260c39662bca@gmail.com> <40fd91d2-d981-2f44-4d58-a3f08a9448fb@familie-gard.de> <2980993.1666242738@sss.pgh.pa.us> <612cf1c4-1f2d-f068-d6cf-54b98bbeb646@gmail.com> <727e6a26-4b58-0aea-a701-9671b8935410@aklaver.com> From: Ron In-Reply-To: <727e6a26-4b58-0aea-a701-9671b8935410@aklaver.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.