pgsql: Fix data checksum progress counter initialization

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix data checksum progress counter initialization
Date: 2026-07-10 13:35:52
Message-ID: E1wiBOR-000SAH-1g@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix data checksum progress counter initialization

pg_stat_progress_data_checksums uses -1 as a sentinel value that is
displayed as NULL for progress counters. However, after
pgstat_progress_start_command() initialized all progress counters to
zero, data checksum progress did not reset those counters to -1.
As a result, some counters could incorrectly appear as zero instead
of NULL. For example, workers could report zero database counters,
and the disabling launcher could report zero relation and block counters.

Also, blocks_done was not reset when a worker started processing
a new relation fork. As a result, it could temporarily exceed blocks_total
or report a stale value for an empty relation fork.

Fix this by initializing the data checksum progress counters to -1
when progress reporting starts for both launcher and worker processes.
Also reset blocks_done together with blocks_total when starting each
relation fork.

Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://postgr.es/m/CAHGQGwEOQyEzW2cqrHEzvwbcsAsuH8MEe7MMidFOFxECy0E1_Q@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e9810253f095f19aab899694f491a1a529f9eb4d

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 8 ++---
src/backend/catalog/system_views.sql | 2 +-
src/backend/postmaster/datachecksum_state.c | 53 ++++++++++++++++++++++-------
src/test/regress/expected/rules.out | 5 ++-
4 files changed, 50 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-07-10 13:36:14 pgsql: Fix data checksum processing for temp relations and dropped data
Previous Message Fujii Masao 2026-07-10 11:38:09 pgsql: postgres_fdw: Mark statistics import helpers as static