Re: Support to define custom wait events for extensions

Masahiro Ikeda <ikedamsh@oss.nttdata.com>

From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, Tristan Partin <tristan@neon.tech>, andres@anarazel.de, pgsql-hackers@lists.postgresql.org
Date: 2023-07-31T07:49:14Z
Lists: pgsql-hackers
On 2023-07-31 16:28, Michael Paquier wrote:
> On Mon, Jul 31, 2023 at 03:53:27PM +0900, Masahiro Ikeda wrote:
>> 	/* This should only be called for user-defined wait event. */
>> 	if (eventId < NUM_BUILTIN_WAIT_EVENT_EXTENSION)
>> 		ereport(ERROR,
>> 				errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> 				errmsg("invalid wait event ID %u", eventId));
>> 
>> I was just wondering if it should also check the eventId
>> that has been allocated though it needs to take the spinlock
>> and GetWaitEventExtensionIdentifier() doesn't take it into account.
> 
> What kind of extra check do you have in mind?  Once WAIT_EVENT_ID_MASK
> is applied, we already know that we don't have something larger than
> PG_UNIT16_MAX, or perhaps you want to cross-check this number with
> what nextId holds in shared memory and that we don't have a number
> between nextId and PG_UNIT16_MAX?  I am not sure that we need to care
> much about that this much in this code path, and I'd rather avoid
> taking an extra time the spinlock just for a cross-check.

OK. I assumed to check that we don't have a number between nextId and
PG_UNIT16_MAX.

Regards,
-- 
Masahiro Ikeda
NTT DATA CORPORATION



Commits

  1. Change custom wait events to use dynamic shared hash tables

  2. Support custom wait events for wait event type "Extension"

  3. Add WAIT_EVENT_{CLASS,ID}_MASK in wait_event.c

  4. worker_spi: Switch to TAP tests

  5. Simplify some conditions related to [LW]Lock in generate-wait_event_types.pl