You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Injection points are a new facility that makes possible for developersto run custom code in pre-defined code paths. Its goal is to provideways to design and run advanced tests, for cases like:- Race conditions, where processes need to do actions in a controlledordered manner.- Forcing a state, like an ERROR, FATAL or even PANIC for OOM, to forcerecovery, etc.- Arbitrary sleeps.This implements some basics, and there are plans to extend it more inthe future depending on what's required. Hence, this commit adds a setof routines in the backend that allows developers to attach, detach andrun injection points:- A code path calling an injection point can be declared with the macroINJECTION_POINT(name).- InjectionPointAttach() and InjectionPointDetach() to respectivelyattach and detach a callback to/from an injection point. An injectionpoint name is registered in a shmem hash table with a library name and afunction name, which will be used to load the callback attached to aninjection point when its code path is run.Injection point names are just strings, so as an injection point can bedeclared and run by out-of-core extensions and modules, with callbacksdefined in external libraries.This facility is hidden behind a dedicated switch for ./configure andmeson, disabled by default.Note that backends use a local cache to store callbacks already loaded,cleaning up their cache if a callback has found to be removed on abest-effort basis. This could be refined further but any tests but whatwe have here was fine with the tests I've written while implementingthese backend APIs.Author: Michael Paquier, with doc suggestions from Ashutosh Bapat.Reviewed-by: Ashutosh Bapat, Nathan Bossart, Álvaro Herrera, DilipKumar, Amul Sul, Nazir Bilal YavuzDiscussion:https://postgr.es/m/ZTiV8tn_MIb_H2rE@paquier.xyz