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 1ju02n-0004Mx-8P for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 20:54:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ju02k-0001lw-Ey for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 20:54:50 +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 1ju02k-0001k0-7Z for pgsql-hackers@lists.postgresql.org; Fri, 10 Jul 2020 20:54:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ju02d-0006uV-7s for pgsql-hackers@lists.postgresql.org; Fri, 10 Jul 2020 20:54:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 06AKseQe2116464; Fri, 10 Jul 2020 16:54:40 -0400 From: Tom Lane To: Justin Pryzby cc: David Gilman , pgsql-hackers@lists.postgresql.org Subject: Re: "tuple concurrently updated" in pg_restore --jobs In-reply-to: <20200706050129.GW4107@telsasoft.com> References: <20200706050129.GW4107@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Mon, 06 Jul 2020 00:01:29 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2116462.1594414480.1@sss.pgh.pa.us> Date: Fri, 10 Jul 2020 16:54:40 -0400 Message-ID: <2116463.1594414480@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > I hit this issue intermittently (roughly half the time) while working with a > patch David submitted, and finally found a recipe to reproduce it on an > unpatched v12 instance. > I was surprised to see pg_restore -j2 is restoring ACLs in pre-data in > parallel. It's not pre-data. But it's true that pg_restore figures it can restore ACLs in parallel during the ACL-restoring pass, on the theory that pg_dump will not emit two different ACL entries for the same object, so that we can do all the catalog updates in parallel without conflicts. This works about 99% of the time, in fact. It falls down in the --clean case if we have to revoke existing table permissions, because in that case the REVOKE at table level is required to clear the table's per-column ACLs as well, so that that ACL entry involves touching the same catalog rows that the per-column ACLs want to touch. I think the right fix is to give the per-column ACL entries dependencies on the per-table ACL, if there is one. This will not fix the problem for the case of restoring from an existing pg_dump archive that lacks such dependency links --- but given the lack of field complaints, I'm okay with that. This looks straightforward, if somewhat tedious because we'll have to change the API of pg_dump's dumpACL() function, which is called by a lot of places. Barring objections, I'll go do that. regards, tom lane