Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION
Date: 2025-06-05 07:26:08
Message-ID: 20250605162608.78674caac737ffe9bdb6dea3@sraoss.co.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 3 Jun 2025 17:39:50 +0900
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:

> On Tue, 27 May 2025 09:00:01 +0300
> Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:

> I know there are other scenarios where the same is raises and I agree that
> it would be better to consider a more global solution instead of addressing
> each of them. However, I am not sure that improving the error message for
> each case doesn't not make sense.

To address the remaining cases where DDL commands fail with the internal
error "ERROR: tuple concurrently updated" due to insufficient locking,
I would like to propose improving the error reporting to produce a more
appropriate and user-facing error message. This should make it easier for
users to understand the cause of the failure.

Patch 0003 improves the error message shown when concurrent updates to a
system catalog tuple occur, producing output like:

ERROR: operation failed due to a concurrent command
DETAIL: Another command modified the same object in a concurrent session.

Patches 0001 and 0002 are unchanged from v2, except for updated commit messages.
I believe these patches are still useful, as they allow the operation to complete
successfully after waiting, or to behave appropriately when the target function
is dropped by another session during the wait.

Best regards,
Yugo Nagata

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

Attachment Content-Type Size
v3-0003-Improve-error-reporting-for-concurrent-updates-on.patch text/x-diff 3.2 KB
v3-0002-Prevent-internal-error-caused-by-concurrent-ALTER.patch text/x-diff 2.2 KB
v3-0001-Prevent-internal-error-at-concurrent-CREATE-OR-RE.patch text/x-diff 3.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-06-05 07:43:49 Re: Fix slot synchronization with two_phase decoding enabled
Previous Message Michael Paquier 2025-06-05 07:22:48 Re: Issues with 2PC at recovery: CLOG lookups and GlobalTransactionData