]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Restrict pg_stat_io entries for data checksum processes
authorFujii Masao <fujii@postgresql.org>
Fri, 17 Jul 2026 11:16:34 +0000 (20:16 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 17 Jul 2026 11:17:50 +0000 (20:17 +0900)
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 <masao.fujii@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAHGQGwHz_-nt+YkHDMRZNBZrnoHro8cMOgSwuXEmSYT6vxgQ=w@mail.gmail.com
Backpatch-through: 19

src/backend/utils/activity/pgstat_io.c
src/test/regress/expected/stats.out

index 38bae7b15d2ed89115f2c0c86630e537073cff80..4f7a39aaa0e8186235c817ef1ae7f54bde5e4fe1 100644 (file)
@@ -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;
 
index bbb1db3c4334737e692e1c9ce45fddac239bcde7..eb11aacfe5a4fa44d29ac1b9a64ece794004263a 100644 (file)
@@ -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;