From: Fujii Masao Date: Fri, 17 Jul 2026 11:16:34 +0000 (+0900) Subject: Restrict pg_stat_io entries for data checksum processes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3aa54433b0cdce48facb610a5b720208cc760654;p=thirdparty%2Fpostgresql.git Restrict pg_stat_io entries for data checksum processes The data checksums launcher and workers were exposed in pg_stat_io with the same broad set of object/context combinations as general background workers. However, several of those entries can never accumulate I/O statistics for these processes, such as bulkwrite, relation init, temporary relation, and launcher vacuum entries. Teach pgstat_tracks_io_object() and pgstat_tracks_io_op() about the actual I/O performed by the data checksum processes. Keep the entries needed for catalog scans, including bulkread catalog scans, worker relation processing with a vacuum access strategy, and WAL writes and initialization, while excluding WAL reads and other object/context combinations that can never be used. Author: Fujii Masao Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com Backpatch-through: 19 --- diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c index 38bae7b15d2..4f7a39aaa0e 100644 --- a/src/backend/utils/activity/pgstat_io.c +++ b/src/backend/utils/activity/pgstat_io.c @@ -464,6 +464,37 @@ pgstat_tracks_io_object(BackendType bktype, IOObject io_object, io_context == IOCONTEXT_BULKWRITE) return false; + /* + * The data checksums launcher scans catalogs and emits WAL records for + * checksum state changes. Catalog scans can use a bulkread strategy. + */ + if (bktype == B_DATACHECKSUMSWORKER_LAUNCHER) + { + if (io_object == IOOBJECT_WAL || + (io_object == IOOBJECT_RELATION && + (io_context == IOCONTEXT_BULKREAD || + io_context == IOCONTEXT_NORMAL))) + return true; + + return false; + } + + /* + * The worker also scans catalogs, then processes relations using a vacuum + * access strategy. Catalog scans can use a bulkread strategy. + */ + if (bktype == B_DATACHECKSUMSWORKER_WORKER) + { + if (io_object == IOOBJECT_WAL || + (io_object == IOOBJECT_RELATION && + (io_context == IOCONTEXT_BULKREAD || + io_context == IOCONTEXT_NORMAL || + io_context == IOCONTEXT_VACUUM))) + return true; + + return false; + } + return true; } @@ -507,6 +538,8 @@ pgstat_tracks_io_op(BackendType bktype, IOObject io_object, if (io_object == IOOBJECT_WAL && io_op == IOOP_READ && (bktype == B_WAL_RECEIVER || bktype == B_BG_WRITER || bktype == B_AUTOVAC_LAUNCHER || bktype == B_AUTOVAC_WORKER || + bktype == B_DATACHECKSUMSWORKER_LAUNCHER || + bktype == B_DATACHECKSUMSWORKER_WORKER || bktype == B_WAL_WRITER)) return false; diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out index bbb1db3c433..eb11aacfe5a 100644 --- a/src/test/regress/expected/stats.out +++ b/src/test/regress/expected/stats.out @@ -52,19 +52,12 @@ client backend|temp relation|normal client backend|wal|init client backend|wal|normal datachecksums launcher|relation|bulkread -datachecksums launcher|relation|bulkwrite -datachecksums launcher|relation|init datachecksums launcher|relation|normal -datachecksums launcher|relation|vacuum -datachecksums launcher|temp relation|normal datachecksums launcher|wal|init datachecksums launcher|wal|normal datachecksums worker|relation|bulkread -datachecksums worker|relation|bulkwrite -datachecksums worker|relation|init datachecksums worker|relation|normal datachecksums worker|relation|vacuum -datachecksums worker|temp relation|normal datachecksums worker|wal|init datachecksums worker|wal|normal io worker|relation|bulkread @@ -111,7 +104,7 @@ walsummarizer|wal|init walsummarizer|wal|normal walwriter|wal|init walwriter|wal|normal -(95 rows) +(88 rows) \a -- ensure that both seqscan and indexscan plans are allowed SET enable_seqscan TO on;