Re: Show WAL write and fsync stats in pg_stat_io

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Nazir Bilal Yavuz <byavuz81@gmail.com>
Cc: Melanie Plageman <melanieplageman@gmail.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>, "bharath.rupireddyforpostgres@gmail.com" <bharath.rupireddyforpostgres@gmail.com>, Thomas Munro <thomas.munro@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: 2025-01-22T00:14:22Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix copy-paste error related to the autovacuum launcher in pgstat_io.c

  2. Move SQL tests of pg_stat_io for WAL data to recovery test 029_stats_restart

  3. Add data for WAL in pg_stat_io and backend statistics

  4. Improve comment on top of pgstat_count_io_op_time()

  5. Refactor pgstat_prepare_io_time() with an input argument instead of a GUC

On Thu, Jan 16, 2025 at 11:40:51AM +0300, Nazir Bilal Yavuz wrote:
> I encountered another problem while rebasing the patch. The problem is
> basically we do not expect any pending stats while restoring the stats
> at the initdb. However, WAL IOs (WAL read and WAL init IOs for now)
> may happen before restoring the stats, so we end up having pending
> stats before restoring them and that causes initdb to fail.

On top of 4feba03d8b92, I've reused something close to the patch you
have posted previously in case, and the issue with allocations for
pending stats should be gone.

Could it be possible to post a new version of the patch?  You should
be able to reuse pgstat_count_backend_io_op[_time]() for your work
with WAL data in pg_stat_io if you need a low-level control of things,
but I suspect that calling pgstat_count_io_op() & the other should be
enough to get the job done with a new IOObject.
--
Michael