Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tl8i6-009bXd-Ak for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2025 15:43:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tl8i4-008TVv-Qq for pgsql-general@arkaria.postgresql.org; Thu, 20 Feb 2025 15:43:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tl8i4-008TUb-F6 for pgsql-general@lists.postgresql.org; Thu, 20 Feb 2025 15:43:32 +0000 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tl8i2-001z5G-1Z for pgsql-general@lists.postgresql.org; Thu, 20 Feb 2025 15:43:32 +0000 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-2b3680e548aso1106415fac.0 for ; Thu, 20 Feb 2025 07:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740066208; x=1740671008; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=syEINesD1HcPLhUhlyV98rOFyWFR9EImrmorLHJse4c=; b=RAAcTLiNtWRye2Ly51erFrmDI3YtTYNmnOuf0UfnxLX12tFPS0keT0vHv62n08Bven EkSVKhPoVOvMoX2iZ46Kl4QkRadw2ztSO+YICnyW43pW1RXFBvMZ8QPRRJ0ElI5MqM1M eOpvgbu9keBv2urpsy29OaF7pprCcytWuvlvutjDGyZggP1/KaoHPEgSkQGsf5hPalZH K5jduYWChF9uDrIUaNc8RPMagC/ju1HVqCYSUiLxOGQEApTK/tJqoOct7+PI06hpMCOc +aFrtgw9XaQGs7JgY9Ux8TiSnyKx3CmtU/d9GGV6jgRwULDYuRXCdjmZxDfVpsawreYm pM6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740066208; x=1740671008; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=syEINesD1HcPLhUhlyV98rOFyWFR9EImrmorLHJse4c=; b=vmRLZ7ePacrlv1Mmh90+2BygvINAE5W/QYZoEl2O7RjkJxhUaxjSrn/dSYTJMz0FHQ WsFvOGCzeFnnA0Z4R6D2HycynXr1/6+KbtmWD0FgazYHjwQchAlVbs8pdIAWiNECgLNu plfycDxWjSzpydUHhoBfRMSTqdOq7mRAjuQbm8Ur8a3sBLm5DKLHT8Nc1T2oCmZa5Ntk /4VZu3Flb3WFyUb+zAUCzGq3G5VZNQJ/mEi0CP2cbreb+l/5tCUb2m2u7cYH7qkqoxr3 XojWlf8pR/44ddTPndrwRxEE+OnelETglbrlJMRcaD7frqJ+oGG5JtjKeya3eP30LWEs 2oug== X-Gm-Message-State: AOJu0YxikaE5HLBSyJztutL99EGdHQnOn0Ys7IUJF+DGj0wHXxEy965B MpsvZsCZt4UtZI1hYqKzZhZcSLh3l/8zLUlA7NYftnPIs2gn6P/Zl8JQj/MR5daPjR/FcUiaSZv rUy7V0zw8iJ5oGa62hrHnm0gjEZw= X-Gm-Gg: ASbGncsuMBnwLS/W1dkJLThY5a5o8pSS5X1JmC94WjlfV+0OZ83DTQ2m0XwtwqOHuVY alGPTkiAoBGmucTylkIGJDK0+Opjdu7/siccBIr0q2vpTCVZqnLM8ec6x12HpSZCieApSYdH1al 8= X-Google-Smtp-Source: AGHT+IFfzoAmsBjZn+wbsjNhFan6TP5Ru3OFUiRN2s30GWVA8gZOfxCwhHoEh7e0b61sSJaBFokVxYy7dpWv5nSXESE= X-Received: by 2002:a05:6871:ea0e:b0:29e:5522:8eeb with SMTP id 586e51a60fabf-2bd2f83c049mr3021170fac.0.1740066208104; Thu, 20 Feb 2025 07:43:28 -0800 (PST) MIME-Version: 1.0 References: <2701260.1740065273@sss.pgh.pa.us> In-Reply-To: <2701260.1740065273@sss.pgh.pa.us> From: Dominique Devienne Date: Thu, 20 Feb 2025 16:43:12 +0100 X-Gm-Features: AWEUYZlP4hTduiybGwiLtixaB1HoujxyHIB9O0PCByfXwble3v8ZubwOBiaPrFQ Message-ID: Subject: Re: #XX000: ERROR: tuple concurrently updated To: Tom Lane Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000384b56062e94bc40" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000384b56062e94bc40 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 20, 2025 at 4:27=E2=80=AFPM Tom Lane wrote: > Dominique Devienne writes: > > Hi. A tester just tried to restore two custom backups (not official > > PostgreSQL ones) 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. > > Since both restores tried to grant some permissions on SCH1, they > both had to update SCH1's pg_namespace row (specifically nspacl). > We have no support for concurrent updates in the catalog-manipulation > code, so if the second run arrives at that step before the first > one has committed its pg_namespace change, you get this error. > Thanks for confirming Tom. > > 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? > > The window is probably too small to hit if each restore is committing > as it goes, but if you run in --single-transaction mode then this > isn't surprising. I'd say don't try to run concurrent restores. > First, I'm not in psql, but my own code. And as mentioned, I'm already in the equivalent, doing everything (DDLs and DMLs) in a single transaction. Second, not doing concurrent restores is not an option. So I need to separate operations related to SCH2,3,..., which are all independent, and SCH1 which is shared, as separate long running and short transactions, respectively. With perhaps some retry logic on the SCH1, just in case. --DD --000000000000384b56062e94bc40 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Feb 20, 2025 at 4:27=E2=80=AFPM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
Dominique Devienne <ddevienne@gmail.com> writes= :
> Hi. A tester just tried to restore two custom backups (not official > PostgreSQL ones) concurrently.
> ...
> The second session completed OK.
> But the first session errors out with:

> Error: DDL Error: GRANT USAGE ON SCHEMA "SCH1", "SCH2&q= uot; TO "SCH2:RO",
> "SCH2:RW", "SCH2:SU": #XX000: ERROR:=C2=A0 tuple c= oncurrently updated

> Thus I'm trying to understand what's going on.

Since both restores tried to grant some permissions on SCH1, they
both had to update SCH1's pg_namespace row (specifically nspacl).
We have no support for concurrent updates in the catalog-manipulation
code, so if the second run arrives at that step before the first
one has committed its pg_namespace change, you get this error.

Thanks for confirming Tom.
=C2=A0
> Is the issue related to trying to change SCHEMA ACLs for SCH1 concurre= ntly,
> in two long running transactions? How am I supposed to resolve this?
The window is probably too small to hit if each restore is committing
as it goes, but if you run in --single-transaction mode then this
isn't surprising.=C2=A0 I'd say don't try to run concurrent res= tores.

First, I'm not in psql, but = my own code. And as mentioned, I'm already in the equivalent,
doing everything (DDLs and DMLs) in a single transaction.

Second, not doing concurrent restores is not an option.
=
So I need to separate operations related to SCH2,3,..., whic= h are all independent,
and SCH1 which is shared, as separate long= running and short transactions, respectively.
With perhaps some = retry logic on the SCH1, just in case. --DD
--000000000000384b56062e94bc40--