pgsql: injection_points: Fix incrementation of variable-numbered stats

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: injection_points: Fix incrementation of variable-numbered stats
Date: 2025-09-17 01:16:27
Message-ID: E1uygmY-0015aI-2o@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

injection_points: Fix incrementation of variable-numbered stats

The pending entry was not used when incrementing its data, directly
manipulating the shared memory pointer, without even locking it. This
could mean losing statistics under concurrent activity. The flush
callback was a no-op.

This code serves as a base template for extensions for the custom
cumulative statistics, so let's be clean and use a pending entry for the
incrementations, whose data is then flushed to the corresponding entry
in the shared hashtable when all the stats are reported, in its own
flush callback.

Author: Sami Imseih <samimseih(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAA5RZ0v0U0yhPbY+bqChomkPbyUrRQ3rQXnZf_SB-svDiQOpgQ@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6e8286f9a15325b6354a682a9106b4035dba0f17

Modified Files
--------------
src/test/modules/injection_points/injection_stats.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-09-17 02:35:56 Re: pgsql: Move named LWLock tranche requests to shared memory.
Previous Message Michael Paquier 2025-09-17 00:33:51 pgsql: Fix shared memory calculation size of PgAioCtl