1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-19 17:02:53 +03:00

injection_points: Remove portions related to custom pgstats

The test module injection_points has been used as a landing spot to
provide coverage for the custom pgstats APIs, for both fixed-sized and
variable-sized stats kinds.  Some recent work related to pgstats is
proving that this structure makes the implementation of new tests
harder.

This commit removes the code related to pgstats from injection_points,
and an equivalent will be reintroduced as a separate test module in a
follow-up commit.  This removal is done in its own commit for clarity.

Using injection_points for this test coverage was perhaps not the best
way to design things, but this was good enough while working on the
first flavor of the custom pgstats APIs.  Using a new test module will
make easier the introduction of new tests, and we will not need to worry
about the impact of new changes related to custom pgstats could have
with the internals of injection_points.

Author: Sami Imseih <samimseih@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0sJgO6GAwgFxmzg9MVP=rM7Us8KKcWpuqxe-f5qxmpE0g@mail.gmail.com
This commit is contained in:
Michael Paquier
2025-12-08 12:45:20 +09:00
parent f68597ee77
commit d52c24b0f8
10 changed files with 0 additions and 697 deletions

View File

@@ -19,7 +19,6 @@
#include "fmgr.h"
#include "funcapi.h"
#include "injection_stats.h"
#include "miscadmin.h"
#include "nodes/pg_list.h"
#include "nodes/value.h"
@@ -107,15 +106,6 @@ extern PGDLLEXPORT void injection_wait(const char *name,
/* track if injection points attached in this process are linked to it */
static bool injection_point_local = false;
/*
* GUC variable
*
* This GUC is useful to control if statistics should be enabled or not
* during a test with injection points, like for example if a test relies
* on a callback run in a critical section where no allocation should happen.
*/
bool inj_stats_enabled = false;
/* Shared memory init callbacks */
static shmem_request_hook_type prev_shmem_request_hook = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
@@ -235,9 +225,6 @@ injection_points_cleanup(int code, Datum arg)
char *name = strVal(lfirst(lc));
(void) InjectionPointDetach(name);
/* Remove stats entry */
pgstat_drop_inj(name);
}
}
@@ -251,8 +238,6 @@ injection_error(const char *name, const void *private_data, void *arg)
if (!injection_point_allowed(condition))
return;
pgstat_report_inj(name);
if (argstr)
elog(ERROR, "error triggered for injection point %s (%s)",
name, argstr);
@@ -269,8 +254,6 @@ injection_notice(const char *name, const void *private_data, void *arg)
if (!injection_point_allowed(condition))
return;
pgstat_report_inj(name);
if (argstr)
elog(NOTICE, "notice triggered for injection point %s (%s)",
name, argstr);
@@ -293,8 +276,6 @@ injection_wait(const char *name, const void *private_data, void *arg)
if (!injection_point_allowed(condition))
return;
pgstat_report_inj(name);
/*
* Use the injection point name for this custom wait event. Note that
* this custom wait event name is not released, but we don't care much for
@@ -371,7 +352,6 @@ injection_points_attach(PG_FUNCTION_ARGS)
condition.pid = MyProcPid;
}
pgstat_report_inj_fixed(1, 0, 0, 0, 0);
InjectionPointAttach(name, "injection_points", function, &condition,
sizeof(InjectionPointCondition));
@@ -385,9 +365,6 @@ injection_points_attach(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldctx);
}
/* Add entry for stats */
pgstat_create_inj(name);
PG_RETURN_VOID();
}
@@ -422,7 +399,6 @@ injection_points_attach_func(PG_FUNCTION_ARGS)
private_data_size = VARSIZE_ANY_EXHDR(private_data);
}
pgstat_report_inj_fixed(1, 0, 0, 0, 0);
if (private_data != NULL)
InjectionPointAttach(name, lib_name, function, VARDATA_ANY(private_data),
private_data_size);
@@ -444,7 +420,6 @@ injection_points_load(PG_FUNCTION_ARGS)
if (inj_state == NULL)
injection_init_shmem();
pgstat_report_inj_fixed(0, 0, 0, 0, 1);
INJECTION_POINT_LOAD(name);
PG_RETURN_VOID();
@@ -467,7 +442,6 @@ injection_points_run(PG_FUNCTION_ARGS)
if (!PG_ARGISNULL(1))
arg = text_to_cstring(PG_GETARG_TEXT_PP(1));
pgstat_report_inj_fixed(0, 0, 1, 0, 0);
INJECTION_POINT(name, arg);
PG_RETURN_VOID();
@@ -490,7 +464,6 @@ injection_points_cached(PG_FUNCTION_ARGS)
if (!PG_ARGISNULL(1))
arg = text_to_cstring(PG_GETARG_TEXT_PP(1));
pgstat_report_inj_fixed(0, 0, 0, 1, 0);
INJECTION_POINT_CACHED(name, arg);
PG_RETURN_VOID();
@@ -567,7 +540,6 @@ injection_points_detach(PG_FUNCTION_ARGS)
{
char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
pgstat_report_inj_fixed(0, 1, 0, 0, 0);
if (!InjectionPointDetach(name))
elog(ERROR, "could not detach injection point \"%s\"", name);
@@ -581,9 +553,6 @@ injection_points_detach(PG_FUNCTION_ARGS)
MemoryContextSwitchTo(oldctx);
}
/* Remove stats entry */
pgstat_drop_inj(name);
PG_RETURN_VOID();
}
@@ -625,32 +594,15 @@ injection_points_list(PG_FUNCTION_ARGS)
#undef NUM_INJECTION_POINTS_LIST
}
void
_PG_init(void)
{
if (!process_shared_preload_libraries_in_progress)
return;
DefineCustomBoolVariable("injection_points.stats",
"Enables statistics for injection points.",
NULL,
&inj_stats_enabled,
false,
PGC_POSTMASTER,
0,
NULL,
NULL,
NULL);
MarkGUCPrefixReserved("injection_points");
/* Shared memory initialization */
prev_shmem_request_hook = shmem_request_hook;
shmem_request_hook = injection_shmem_request;
prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = injection_shmem_startup;
pgstat_register_inj();
pgstat_register_inj_fixed();
}