Re: Support to define custom wait events for extensions

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2023-07-12T08:46:31Z
Lists: pgsql-hackers
On Wed, Jul 12, 2023 at 04:52:38PM +0900, Masahiro Ikeda wrote:
> In my understanding, the first column of the row for WaitEventExtension in
> wait_event_names.txt can be any value and the above code should not die.
> But if I use the following input, it falls on the last line.
> 
>  # wait_event_names.txt
>  Section: ClassName - WaitEventExtension
> 
>  WAIT_EVENT_EXTENSION	"Extension"	"Waiting in an extension."
>  Extension	"Extension"	"Waiting in an extension."
>  EXTENSION	"Extension"	"Waiting in an extension."
> 
> If the behavior is unexpected, we need to change the current code.
> I have created a patch for the areas that I felt needed to be changed.
> - 0001-change-the-die-condition-in-generate-wait_event_type.patch
>  (In addition to the above, "$continue = ",\n";" doesn't appear to be
> necessary.)

    die "wait event names must start with 'WAIT_EVENT_'"
      if ( $trimmedwaiteventname eq $waiteventenumname
-       && $waiteventenumname !~ /^LWLock/
-       && $waiteventenumname !~ /^Lock/);
-   $continue = ",\n";
+       && $waitclassname !~ /^WaitEventLWLock$/
+       && $waitclassname !~ /^WaitEventLock$/);

Indeed, this looks wrong as-is.  $waiteventenumname refers to the
names of the enum elements, so we could just apply a filter based on
the class names in full.  The second check in for the generation of
the c/h files uses the class names.
--
Michael

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