Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION
Date: 2025-05-26 18:17:51
Message-ID: 20250527031751.5434e5bcc383e0777b9c93eb@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 23 May 2025 10:37:42 +0800
jian he <jian(dot)universality(at)gmail(dot)com> wrote:

> On Thu, May 22, 2025 at 10:25 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> >
> hi.
> earlier, i didn't check patch 0002.
>
> i think in AlterFunction add
> /* Lock the function so nobody else can do anything with it. */
> LockDatabaseObject(ProcedureRelationId, funcOid, 0, AccessExclusiveLock);
>
> right after
> funcOid = LookupFuncWithArgs(stmt->objtype, stmt->func, false);
>
> should be fine.

Thank you. That makes sense because we can reduce redundant call of SearchSysCacheCopy1
and HeapTupleIsValid. I've attached a updated patch.

Regards,
Yugo Nagata

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

Attachment Content-Type Size
v2-0002-Prevent-internal-error-at-concurrent-ALTER-FUNCTI.patch text/x-diff 1.7 KB
v2-0001-Prevent-internal-error-at-concurrent-CREATE-OR-RE.patch text/x-diff 2.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-05-26 19:36:14 Re: Fixing memory leaks in postgres_fdw
Previous Message Yugo Nagata 2025-05-26 17:35:30 Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION