42#define INJ_NAME_MAXLEN 64
45#define INJ_WAIT_INITIAL_US 10
46#define INJ_WAIT_MAX_US 100000
76 const void *private_data,
79 const void *private_data,
82 const void *private_data,
158 switch (condition->
type)
204 elog(
ERROR,
"error triggered for injection point %s (%s)",
220 elog(
NOTICE,
"notice triggered for injection point %s (%s)",
266 elog(
ERROR,
"could not find free slot for wait of injection point %s",
305 if (
strcmp(action,
"error") == 0)
307 else if (
strcmp(action,
"notice") == 0)
309 else if (
strcmp(action,
"wait") == 0)
312 elog(
ERROR,
"incorrect action \"%s\" for injection point creation", action);
351 elog(
ERROR,
"injection point name cannot be NULL");
353 elog(
ERROR,
"injection point library cannot be NULL");
355 elog(
ERROR,
"injection point function cannot be NULL");
367 if (private_data !=
NULL)
463 elog(
ERROR,
"could not find injection point %s to wake up",
name);
507 elog(
ERROR,
"could not detach injection point \"%s\"",
name);
529#define NUM_INJECTION_POINTS_LIST 3
546 memset(nulls, 0,
sizeof(nulls));
557#undef NUM_INJECTION_POINTS_LIST
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
static Datum values[MAXATTR]
void * GetNamedDSMSegment(const char *name, size_t size, void(*init_callback)(void *ptr, void *arg), bool *found, void *arg)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define PG_FUNCTION_INFO_V1(funcname)
void InitMaterializedSRF(FunctionCallInfo fcinfo, uint32 flags)
bool InjectionPointDetach(const char *name)
List * InjectionPointList(void)
void InjectionPointAttach(const char *name, const char *library, const char *function, const void *private_data, int private_data_size)
#define INJECTION_POINT(name, arg)
#define INJECTION_POINT_CACHED(name, arg)
#define INJECTION_POINT_LOAD(name)
Datum injection_points_detach(PG_FUNCTION_ARGS)
static bool injection_point_local
static void injection_point_init_state(void *ptr, void *arg)
PGDLLEXPORT void injection_wait(const char *name, const void *private_data, void *arg)
static void injection_init_shmem(void)
Datum injection_points_cached(PG_FUNCTION_ARGS)
#define INJ_WAIT_INITIAL_US
Datum injection_points_attach(PG_FUNCTION_ARGS)
Datum injection_points_run(PG_FUNCTION_ARGS)
static List * inj_list_local
static bool injection_point_allowed(const InjectionPointCondition *condition)
Datum injection_points_set_local(PG_FUNCTION_ARGS)
static void injection_shmem_init(void *arg)
static void injection_points_cleanup(int code, Datum arg)
PGDLLEXPORT void injection_error(const char *name, const void *private_data, void *arg)
static const ShmemCallbacks injection_shmem_callbacks
static void injection_shmem_request(void *arg)
Datum injection_points_attach_func(PG_FUNCTION_ARGS)
#define NUM_INJECTION_POINTS_LIST
Datum injection_points_wakeup(PG_FUNCTION_ARGS)
PGDLLEXPORT void injection_notice(const char *name, const void *private_data, void *arg)
Datum injection_points_list(PG_FUNCTION_ARGS)
static InjectionPointSharedState * inj_state
Datum injection_points_load(PG_FUNCTION_ARGS)
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
List * lappend(List *list, void *datum)
List * list_delete(List *list, void *datum)
char * pstrdup(const char *in)
MemoryContext TopMemoryContext
#define CHECK_FOR_INTERRUPTS()
bool process_shared_preload_libraries_in_progress
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
on_exit_nicely_callback function
size_t strlcpy(char *dst, const char *src, size_t siz)
#define PointerGetDatum(X)
void RegisterShmemCallbacks(const ShmemCallbacks *callbacks)
#define ShmemRequestStruct(...)
void pg_usleep(long microsec)
static void SpinLockRelease(volatile slock_t *lock)
static void SpinLockAcquire(volatile slock_t *lock)
static void SpinLockInit(volatile slock_t *lock)
InjectionPointConditionType type
pg_atomic_uint32 wait_counts[INJ_MAX_WAIT]
char name[INJ_MAX_WAIT][INJ_NAME_MAXLEN]
ShmemRequestCallback request_fn
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
String * makeString(char *str)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
uint32 WaitEventInjectionPointNew(const char *wait_event_name)
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)