pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: injection_points: Add some cumulative stats for injection points
Date: Mon, 05 Aug 2024 03:09:34 +0000
Message-ID: <E1sao6I-002j5T-GN@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1sao6I-002j5T-GN@gemulon.postgresql.org>
Permalink:  ../E1sao6I-002j5T-GN@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sao6I-002j5T-GN@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: injection_points: Add some cumulative stats for injection points
  In-Reply-To: <E1sao6I-002j5T-GN@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox