| 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 17:35:30 |
| Message-ID: | 20250527023530.9d00f93472f6ddebded37ce8@sraoss.co.jp |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Thu, 22 May 2025 10:25:58 +0800
jian he <jian(dot)universality(at)gmail(dot)com> wrote:
Thank you for looking into it.
> + /* Lock the function so nobody else can do anything with it. */
> + LockDatabaseObject(ProcedureRelationId, oldproc->oid, 0, AccessExclusiveLock);
> +
> + /*
> + * It is possible that by the time we acquire the lock on function,
> + * concurrent DDL has removed it. We can test this by checking the
> + * existence of function. We get the tuple again to avoid the risk
> + * of function definition getting changed.
> + */
> + oldtup = SearchSysCacheCopy3(PROCNAMEARGSNSP,
> + PointerGetDatum(procedureName),
> + PointerGetDatum(parameterTypes),
> + ObjectIdGetDatum(procNamespace));
>
> we already called LockDatabaseObject, concurrent DDL can
> not do DROP FUNCTION or ALTER FUNCTION.
> so no need to call SearchSysCacheCopy3 again?
The function may be dropped *before* we call LockDatabaseObject.
SearchSysCacheCopy3 is called for check this.
Plese see AlterPublication() as a similar code example.
>
> @@ -553,11 +575,13 @@ ProcedureCreate(const char *procedureName,
> replaces[Anum_pg_proc_proowner - 1] = false;
> replaces[Anum_pg_proc_proacl - 1] = false;
>
> +
> +
> /* Okay, do it... */
> no need to add these two new lines.
I'll remove the lines. Thanks.
Regards,
Yugo Nagata
--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Yugo Nagata | 2025-05-26 18:17:51 | Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION |
| Previous Message | Alexander Korotkov | 2025-05-26 17:06:23 | Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly |