Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: "Aya Iwata (Fujitsu)" <iwata(dot)aya(at)fujitsu(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE
Date: 2025-10-15 03:37:05
Message-ID: 468D0F1F-1959-4FEC-A16D-C3B3AB7C8730@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Oct 10, 2025, at 17:04, Aya Iwata (Fujitsu) <iwata(dot)aya(at)fujitsu(dot)com> wrote:
>
>> 3 - bgworker.h
>> ```
>> +extern void TerminateBackgroundWorkersByOid(Oid databaseId);
>> ```
>>
>> An OID can represent a lot of things. So, instead of suggesting the OID type by parameter name, I wonder if it is better do that with the function name, like TerminateBgWorkersByDbOid(Oid oid)
>
> After receiving your comment, I checked other functions and there is no other examples like XXOid function in the code.
> If this function use only here, original code is using databaseId in argument and it clear what Oid is.
> I think original name is fine because it's not a function that's called much elsewhere.

By searching for “ByOid”, we can get some existing examples:

ObjectAddress
RefreshMatViewByOid(Oid matviewOid, bool is_create, bool skipData,
bool concurrent, const char *queryString,
QueryCompletion *qc)

The function name clearly tells refresh MatView by Oid, so the oid in parameter is an old of mat view.

ResultRelInfo *
ExecLookupResultRelByOid(ModifyTableState *node, Oid resultoid,
bool missing_ok, bool update_cache)

The function name indicates ResultRel, so the oid is a result oid.

AccessMethodInfo *
findAccessMethodByOid(Oid oid)

The function name tells to find access method, the the oid is an access method’s OID.

You can find more …

But in this patch, the function name only indeeds “terminate background workers”, while the oid is a database oid. Maybe we can rename the function to “TerminateDatabaseBgWorkersByOid()”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-10-15 04:00:07 Re: IO in wrong state on riscv64
Previous Message Joel Jacobson 2025-10-15 03:22:59 Re: Optimize LISTEN/NOTIFY