Re: pg_stat_database.checksum_failures misses single-page failures in backups

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Yilin Zhang <jiezhilove(at)126(dot)com>
Subject: Re: pg_stat_database.checksum_failures misses single-page failures in backups
Date: 2026-08-17 22:50:27
Message-ID: aoOQMybnRDTIb07c@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 17, 2026 at 05:32:09PM +0300, Nazir Bilal Yavuz wrote:
> I was reading the related thread [1] and I think you are right, it is
> an oversight. Your analysis and fix look correct to me.

Fun one. On corruption I feel that it would be unlikely to see only 1
failure after a large scan. That's still wrong. :)

if (checksum_failures > 1)
- {
ereport(WARNING,
(errmsg_plural("file \"%s\" has a total of %d checksum verification failure",
"file \"%s\" has a total of %d checksum verification failures",
checksum_failures,
readfilename, checksum_failures)));

+ if (checksum_failures > 0)
+ {
pgstat_prepare_report_checksum_failure(dboid);
pgstat_report_checksum_failures_in_db(dboid, checksum_failures);
}

While the report is right, the resulting patch looks incorrect to me.
It seems to me that we should also report the warning if we have
checksum_failures == 1. errmsg_plural() would use the non-plural
message in this case. So it looks like we should just switch
"checksum_failures > 1" to "checksum_failures > 0".

Adding a test case seems like a good idea. Your proposal is cheap.
Cheap is good.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-08-17 23:01:01 Re: pg_stat_database.checksum_failures misses single-page failures in backups
Previous Message surya poondla 2026-08-17 22:33:53 Re: Compression of bigger WAL records