Re: Add support for entry counting in pgstats - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add support for entry counting in pgstats
Date
Msg-id aNnPlJQt-dgFYX-W@paquier.xyz
Whole thread Raw
In response to Re: Add support for entry counting in pgstats  (Sami Imseih <samimseih@gmail.com>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: create table like including storage parameter
Next
From: Michael Paquier
Date:
Subject: Fix locking issue with fixed-size stats template in injection_points