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 <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: 
https://postgr.es/m/cahgqgweoqyezw2cqrhezvwbcsasuh8mee7mmidfofxecy0e...@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(-)

Reply via email to