Re: Adding per backend commit and rollback counters

From: Nishant Sharma <nishant(dot)sharma(at)enterprisedb(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Kuba Knysiak <thesniboy(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding per backend commit and rollback counters
Date: 2026-07-06 11:41:37
Message-ID: CADrsxda_=msBd+bkHJT2_=QbbPe2rCFQfuDJByVD+nug7vVjKQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the v5 patch set!

Here are my review comments:
1) Patches need re-base. Not able to apply.

2) PGSTAT_BACKEND_FLUSH_XACT collision with newly committed
PGSTAT_BACKEND_FLUSH_LOCK.

3) What if pgStatXactCommit and pgStatXactRollback are 0? We unnecessarily
make backend_has_xactstats as true while updating the pending struct
values. In this process unnecessary ref_lock would be taken and
stats.xact_commit, stats.xact_rollback would be updated with 0 and then
ref_lock is unlocked.

4) PendingBackendStats was static but it was removed in this change, yet
the comment above still mentions it. Also it is killing the purpose of
"Utility routines to report I/O stats for backends ..." comment mentioned
in pgstat_backend.c. It appears the existing helper I/O routines' purpose
is eliminated. This doesn't look good.

4) I don't see any function using plural form like
pg_stat_get_backend_transactions in pg_proc.dat

5) The thread started with only commit and rollback counters, but xid was
added in v3, along with the idea of adding more, such as "seqscans, vacuum
count, analyze count...". This makes me curious: why can't these other
counters be added in this same thread? If these others aren't added now,
why was xid added? I suggest this thread should only include commit and
rollback counters, and xid should be added with the other metrics in a new
thread.

Regards,
Nishant Sharma,
EDB, Pune.
https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-07-06 11:43:12 Re: allow spread checkpoints when changing checksums online
Previous Message Jakub Wartak 2026-07-06 11:41:13 Re: pg_stat_io_histogram