diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-08-23 11:36:41 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-08-23 11:36:41 +0900 |
commit | 2e35c67f956891b2dd7c30fbac9a14e76377300a (patch) | |
tree | eaae84e11cccb639475bc7f8c6acdbdf7bfe350b /src/test/modules/injection_points/injection_points.c | |
parent | b2b023aa3706ec6b3978708545301f7436205c6d (diff) | |
download | postgresql-2e35c67f956891b2dd7c30fbac9a14e76377300a.tar.gz postgresql-2e35c67f956891b2dd7c30fbac9a14e76377300a.zip |
injection_point: Add injection_points.stats
This GUC controls if cumulative statistics are enabled or not in the
module. Custom statistics require the module to be loaded with
shared_preload_libraries, hence this GUC is made PGC_POSTMASTER. By
default, the stats are disabled. 001_stats.pl is updated to enable the
statistics, as it is the only area where these are required now.
This will be used by an upcoming change for the injection point test
added by 768a9fd5535f where stats should not be used, as the test runs a
point callback in a critical section. And the module injection_points
will need to be loaded with shared_preload_libraries there.
Per discussion with Álvaro Herrera.
Author: Michael Paquier
Discussion: https://postgr.es/m/ZsUnJUlSOBNAzwW1@paquier.xyz
Diffstat (limited to 'src/test/modules/injection_points/injection_points.c')
-rw-r--r-- | src/test/modules/injection_points/injection_points.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c index abb1516e124..6bcde7b34e8 100644 --- a/src/test/modules/injection_points/injection_points.c +++ b/src/test/modules/injection_points/injection_points.c @@ -28,6 +28,7 @@ #include "storage/lwlock.h" #include "storage/shmem.h" #include "utils/builtins.h" +#include "utils/guc.h" #include "utils/injection_point.h" #include "utils/memutils.h" #include "utils/wait_event.h" @@ -102,6 +103,15 @@ 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; @@ -513,6 +523,19 @@ _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; |