]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix pgstat_count_io_op_time() calls passing incorrect information
authorMichael Paquier <michael@paquier.xyz>
Wed, 17 Jun 2026 07:05:11 +0000 (16:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 17 Jun 2026 07:05:11 +0000 (16:05 +0900)
commit3048e81308f9d0ebe62214b56c8ea3da42e45851
treef1f8a4ae19b72864295463370a489a41dc3bc10f
parentf29299c42b0b7877db0c339147d95524be69b4e6
Fix pgstat_count_io_op_time() calls passing incorrect information

Several calls of pgstat_count_io_op_time() have been used as data to
count negative values returned by pg_pread() or pg_pwrite(), leading to
an incorrect count reported, casting them back to uint64.

Most of the problematic calls updated here are adjusted so as we do not
report buggy negative numbers anymore.  In xlogrecovery.c, the spot
updated still counts short reads.  In xlog.c, after a WAL segment
initialization, I/O numbers are aggregated only after checking that the
operation has succeeded.

issues introduced by a051e71e28a1.

Reported-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/0db864e6-4477-4eba-b2be-d3523cc86564@eisentraut.org
Backpatch-through: 18
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogreader.c
src/backend/access/transam/xlogrecovery.c
src/backend/replication/walreceiver.c