
Injection points are a new facility that makes possible for developers to run custom code in pre-defined code paths. Its goal is to provide ways to design and run advanced tests, for cases like: - Race conditions, where processes need to do actions in a controlled ordered manner. - Forcing a state, like an ERROR, FATAL or even PANIC for OOM, to force recovery, etc. - Arbitrary sleeps. This implements some basics, and there are plans to extend it more in the future depending on what's required. Hence, this commit adds a set of routines in the backend that allows developers to attach, detach and run injection points: - A code path calling an injection point can be declared with the macro INJECTION_POINT(name). - InjectionPointAttach() and InjectionPointDetach() to respectively attach and detach a callback to/from an injection point. An injection point name is registered in a shmem hash table with a library name and a function name, which will be used to load the callback attached to an injection point when its code path is run. Injection point names are just strings, so as an injection point can be declared and run by out-of-core extensions and modules, with callbacks defined in external libraries. This facility is hidden behind a dedicated switch for ./configure and meson, 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 a best-effort basis. This could be refined further but any tests but what we have here was fine with the tests I've written while implementing these backend APIs. Author: Michael Paquier, with doc suggestions from Ashutosh Bapat. Reviewed-by: Ashutosh Bapat, Nathan Bossart, Álvaro Herrera, Dilip Kumar, Amul Sul, Nazir Bilal Yavuz Discussion: https://postgr.es/m/ZTiV8tn_MIb_H2rE@paquier.xyz
46 lines
938 B
Makefile
46 lines
938 B
Makefile
#-------------------------------------------------------------------------
|
|
#
|
|
# Makefile--
|
|
# Makefile for utils/misc
|
|
#
|
|
# IDENTIFICATION
|
|
# src/backend/utils/misc/Makefile
|
|
#
|
|
#-------------------------------------------------------------------------
|
|
|
|
subdir = src/backend/utils/misc
|
|
top_builddir = ../../../..
|
|
include $(top_builddir)/src/Makefile.global
|
|
|
|
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
|
|
|
|
OBJS = \
|
|
conffiles.o \
|
|
guc.o \
|
|
guc-file.o \
|
|
guc_funcs.o \
|
|
guc_tables.o \
|
|
help_config.o \
|
|
injection_point.o \
|
|
pg_config.o \
|
|
pg_controldata.o \
|
|
pg_rusage.o \
|
|
ps_status.o \
|
|
queryenvironment.o \
|
|
rls.o \
|
|
sampling.o \
|
|
superuser.o \
|
|
timeout.o \
|
|
tzparser.o
|
|
|
|
# This location might depend on the installation directories. Therefore
|
|
# we can't substitute it into pg_config.h.
|
|
ifdef krb_srvtab
|
|
override CPPFLAGS += -DPG_KRB_SRVTAB='"$(krb_srvtab)"'
|
|
endif
|
|
|
|
include $(top_srcdir)/src/backend/common.mk
|
|
|
|
clean:
|
|
rm -f guc-file.c
|