public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dominique Devienne <[email protected]>
To: [email protected]
Subject: #XX000: ERROR: tuple concurrently updated
Date: Thu, 20 Feb 2025 15:31:35 +0100
Message-ID: <CAFCRh-8g-41VhdbbbnP+eezFq1UJ6T2JdQ=iS60hcaqGoJ=x9w@mail.gmail.com> (raw)

Hi. A tester just tried to restore two custom backups (not official
PostgreSQL ones) concurrently.
The restore process creates a new schema, some roles,and does some
role-to-role grants, before loading the data.

The two restores are independent, i.e. create different non-overlapping
schemas.
But both are "registered" in the same pre-existing schema, SCH1.
And both run within a single transaction, that does everything, DDLs and
DMLs.

The first session was doing a longer bigger restore, and was started first.
While the second session was doing a faster shorter one, and started a few
seconds later, concurrently.

The second session completed OK.
But the first session errors out with:

Error: DDL Error: GRANT USAGE ON SCHEMA "SCH1", "SCH2" TO "SCH2:RO",
"SCH2:RW", "SCH2:SU": #XX000: ERROR:  tuple concurrently updated

Thus I'm trying to understand what's going on.
As noted above, SCH1 is the pre-existing schema, while SCH2 is the new one
created by the restore.

The second session that completes normally did a `GRANT USAGE ON SCHEMA
"SCH1", "SCH3" TO "SCH3:RO", "SCH3:RW", "SCH3:SU"` within its own
transaction.

When I research #XX000, it often mentions doing a SELECT FOR UPDATE, but
here I'm doing GRANTs, so I don't think that applies.

Is the issue related to trying to change SCHEMA ACLs for SCH1 concurrently,
in two long running transactions? How am I supposed to resolve this?

I have to confess being a little surprised and blindsided by this issue.
Help understanding what's going on, and how to fix it, would be greatly
appreciated.

Thanks, --DD


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: #XX000: ERROR: tuple concurrently updated
  In-Reply-To: <CAFCRh-8g-41VhdbbbnP+eezFq1UJ6T2JdQ=iS60hcaqGoJ=x9w@mail.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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox