Re: injection points for hash aggregation

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: injection points for hash aggregation
Date: 2025-02-04 00:21:49
Message-ID: Z6FdndJKgCfCyF27@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 03, 2025 at 12:45:24PM -0800, Jeff Davis wrote:
> A couple questions on the injection points framework:
>
> * The patch allows forcing the partition fan-out to one. I could
> imagine forcing it to a specific value, is there a way to do that?
>
> * The injection_points extension offers the concept of a "local"
> injection point. While that makes sense for the callback function, it
> doesn't make sense when using the "local_var = 123" style, because that
> will happen regardless of the condition, right?
>
> * Callbacks are given very little context from the injection point
> itself, so it's hard for me to imagine what a callback might do other
> than logging the name of the injection point or waiting (as the
> extension implements). What else would callbacks be good for?

Being able to pass down some runtime states to a callback is something
I've drafted a patch for, as of:
https://www.postgresql.org/message-id/Z23zcE4w1djukkva@paquier.xyz

There was no real agreement if this facility was worth having or not,
because there were no use case for it. Well, perhaps until now based
on what you are saying.

If you want to force a callback to use a specific value or trigger
conditions based on that, you could add your own new callback in the
module injection_points and give it some custom data when attaching
the point, with a SQL function that uses InjectionPointAttach()'s
private_data. Then you could rely on injection_point_allowed(), for
example, to decide if a callback is run or not. So it depends on if
you want to use data known when attaching a callback or do something
based on a state given by a backend when it runs an attached callback.

Something worth mentioning. Heikki and Peter G. have mentioned to me
at the last pgconf.dev that it could be nice to allow files to hold
their own callbacks rather than have an extension do that (don't
recall there is a footprint about that on the lists, that was an
informal offline discussion). This would have the advantage to limit
the number of code-path-specific callbacks in the injection_points
module (or just limit the number of modules), with callbacks only
existing locally where they are used. IS_INJECTION_POINT_ATTACHED()
is what I see as a a simplified version of this idea.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-02-04 00:33:27 Question -- why is there no errhint_internal function?
Previous Message Jeff Davis 2025-02-03 23:54:27 Re: injection points for hash aggregation