Re: Add support for entry counting in pgstats

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add support for entry counting in pgstats
Date: 2025-09-29 00:15:16
Message-ID: aNnPlJQt-dgFYX-W@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 26, 2025 at 12:09:45PM -0500, Sami Imseih wrote:
> Thanks for v3. The only remaining comment I have is:

Thanks for the extra lookup. I have fixed this one, incorporated the
feedback from Chao, and applied the result after more tests with
pgbench to check the state of the counter.

With more concurrency and an instance set up like that in
postgresql.conf:
shared_preload_libraries = 'injection_points'
injection_points.stats = on

And of course that:
psql -c 'create extension injection_points'

Then with the following flow, checking that the count never gets
higher than the number of clients:
1) pgbench -n -T 300 -f create_inj.sql -c 10
$ cat create_inj.sql
\set id random(1,100000)
select injection_points_attach('popo:id', 'notice');
select injection_points_run('popo:id');
select injection_points_detach('popo:id');
2) pgbench -n -T 300 -f select_inj.sql -c 10
$ cat select_inj.sql
\set id random(1,100000)
select injection_points_stats_numcalls('popo:id');
3) psql session:
select injection_points_stats_count();
\watch 1

And I have found, cough, a rather embarrassing bug on the way,
unrelated to the proposal of this thread. It's in the module
injection_points for its fixed stats, so nothing ground-breaking,
still embarrassing. Will post a fix on a new thread shortly..
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-09-29 00:48:44 Fix locking issue with fixed-size stats template in injection_points
Previous Message jian he 2025-09-29 00:00:00 create table like including storage parameter