Injection points: preloading and runtime arguments
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-05-20T03:18:43Z
Lists: pgsql-hackers
Attachments
- 0001-Extend-injection-points-with-optional-runtime-argume.patch (text/x-diff) patch 0001
- 0002-Support-preloading-of-injection-points.patch (text/x-diff) patch 0002
Hi all, I have a couple of extra toys for injection points in my bucket that I'd like to propose for integration in v18, based on some feedback I have received: 1) Preload an injection point into the backend-level cache without running it. This has come up because an injection point run for the first time needs to be loaded with load_external_function that internally does some allocations, and this would not work if the injection point is in a critical section. Being able to preload an injection point requires an extra macro, called INJECTION_POINT_PRELOAD. Perhaps "load" makes more sense as keyword, here. 2) Grab values at runtime from the code path where an injection point is run and give them to the callback. The case here is to be able to do some dynamic manipulation or a stack, reads of some runtime data or even decide of a different set of actions in a callback based on what the input has provided. One case that I've been playing with here is the dynamic manipulation of pages in specific code paths to stress internal checks, as one example. This introduces a 1-argument version, as multiple args could always be passed down to the callback within a structure. The in-core module injection_points is extended to provide a SQL interface to be able to do the preloading or define a callback with arguments. The two changes are split into patches of their own. These new facilities could be backpatched if there is a need for them in the future in stable branches, as these are aimed for tests and the changes do not introduce any ABI breakages with the existing APIs or the in-core module. Thoughts and comments are welcome. -- Michael
Commits
-
Add INJECTION_POINT_CACHED() to run injection points directly from cache
- a0a5869a8598 18.0 landed
-
Support loading of injection points
- 4b211003ecc2 18.0 landed