pgsql: injection_points: Add proper locking when reporting fixed-variab

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: injection_points: Add proper locking when reporting fixed-variab
Date: 2025-09-30 00:03:08
Message-ID: E1v3Npk-000hQW-0p@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

injection_points: Add proper locking when reporting fixed-variable stats

Contrary to its siblings for the archiver, the bgwriter and the
checkpointer stats, pgstat_report_inj_fixed() can be called
concurrently. This was causing an assertion failure, while messing up
with the stats.

This code is aimed at being a template for extension developers, so it
is not a critical issue, but let's be correct. This module has also
been useful for some benchmarking, at least for me, and that was how I
have discovered this issue.

Oversight in f68cd847fa40.

Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
Discussion: https://postgr.es/m/aNnXbAXHPFUWPIz2@paquier.xyz
Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b5f898944d1226f8daeb0bda58098f645582c80f

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

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-09-30 00:39:45 pgsql: Reorder XLogNeedsFlush() checks to be more consistent
Previous Message Tom Lane 2025-09-29 20:55:22 pgsql: Add GROUP BY ALL.