Re: faulty error handling around pgstat_count_io_op_time()

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-06-17T05:12:34Z
Lists: pgsql-hackers
Hi,

On Wed, Jun 17, 2026 at 09:26:22AM +0900, Michael Paquier wrote:
> 
> In XLogFileInitInternal(), the first pgstat_count_io_op_time() is not
> completely right, no?  pg_pwrite_zeros() or pg_pwrite() could fail,
> and it does not make sense to me to count data if we have a
> save_errno, and the files are unlinked in the error path.  I'd propose
> to delay the count() call to happen after the error check is done.

I think you are right. This one was not handled because it's not a type
conversion bug but we should not count I/O on a failed operation.

> This leads me to the v2 attached.  This is your v1 plus the extra
> change for XLogFileInitInternal() when the segments are initialized.

LGTM.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



Commits

  1. Fix pgstat_count_io_op_time() calls passing incorrect information