Re: Redesign per-backend statistics

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Sami Imseih <samimseih(at)gmail(dot)com>
Subject: Re: Redesign per-backend statistics
Date: 2026-11-25 04:33:08
Message-ID: awZlBD2qMoOFqbff@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 09, 2026 at 09:16:39AM +0000, Bertrand Drouvot wrote:
> As a result, 0003-0005 no longer add direct WAL, lock and I/O accumulation calls.
> 0006 also renames pgstat_per_backend.c to pgstat_backend.c after removing the
> existing PGSTAT_KIND_BACKEND implementation.
>
> Also, as mentioned up-thread, support for custom per-backend statistics is left
> for a follow-up.

Looked at 0001, to start with something.

+# a shared WAL reset should set the reset timestamp for live backends
+permutation s1_reset_shared s1_check_reset

This is the last permutation of the isolation test, and as far as I
can see this is not really valid when taken in isolation.
The expected state of s1_check_reset comes from the previous step,
actually, due to the connections being opened once. So I've removed
this part and the step s1_reset_shared. Permutation 4 looks OK,
though, with the per-backend reset. If you have more ideas that could
be added here, feel free, just checking that the reset timestamp is
updated once is sufficient to me.

+# Resetting s2's stats resets its timestamp.
+permutation s1_reset_backend s1_check_reset

This one now uses an extra s1_check_reset before the s1_reset_backend,
so as we check that nothing in the test has the idea to kick a
timestamp reset beforehand. Your test was slightly weaker written
as-is.

Not sure that I like much the placement of the TAP test in
029_stats_restart.pl, which has nothing to do about snapshot
consistency. I see why you are using TAP, of course, as you want to
check that backends are excluded when these connect to the server
after a snapshot has been built. The tool is right, the location is
not. Perhaps something like test_misc, in a manner similar to the
lock stats, would be better?

The regression test is fine. I have tweaked a few more things in the
isolation test (name, comment simplifications and additions), and
applied the result as it is already a nice cut. Nice coverage
additions! That's one less patch to worry about, at least a good
chunk of it.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-11-25 04:37:19 Re: Simplify the uniqueness proof for self-join elimination
Previous Message Andreas Karlsson 2026-11-25 04:23:06 Re: Small cleanup of leftover pre-1.1.0 OpenSSL code