pgsql: injection_points: Add some cumulative stats for injection points - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: injection_points: Add some cumulative stats for injection points
Date
Msg-id E1sao6I-002j5T-GN@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
injection_points: Add some cumulative stats for injection points

This acts as a template of what can be achieved with the pluggable
cumulative stats APIs introduced in 7949d9594582 for the
variable-numbered case where stats entries are stored in the pgstats
dshash, while being potentially useful on its own for injection points,
say to add starting and/or stopping conditions based on the statistics
(want to trigger a callback after N calls, for example?).

Currently, the only data gathered is the number of times an injection
point is run.  More fields can always be added as required.  All the
routines related to the stats are located in their own file, called
injection_stats.c in the test module injection_points, for clarity.

The stats can be used only if the test module is loaded through
shared_preload_libraries.  The key of the dshash uses InvalidOid for the
database, and an int4 hash of the injection point name as object ID.

A TAP test is added to provide coverage for the new custom cumulative
stats APIs, showing the persistency of the data across restarts, for
example.

Author: Michael Paquier
Reviewed-by: Dmitry Dolgov, Bertrand Drouvot
Discussion: https://postgr.es/m/Zmqm9j5EO0I4W8dx@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/75534436a477474ea05004b7fbed21e20cea774a

Modified Files
--------------
doc/src/sgml/xfunc.sgml                            |   5 +
src/test/modules/injection_points/Makefile         |  11 +-
.../injection_points/injection_points--1.0.sql     |  10 ++
.../modules/injection_points/injection_points.c    |  27 +++
.../modules/injection_points/injection_stats.c     | 197 +++++++++++++++++++++
.../modules/injection_points/injection_stats.h     |  23 +++
src/test/modules/injection_points/meson.build      |   9 +
src/test/modules/injection_points/t/001_stats.pl   |  50 ++++++
src/tools/pgindent/typedefs.list                   |   2 +
9 files changed, 332 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Add helper routines to retrieve data for custom fixed-numbered p
Next
From: Michael Paquier
Date:
Subject: pgsql: injection_points: Add some fixed-numbered statistics