pgsql: Fix mis-attribution of checksum failure stats to the wrong datab - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Fix mis-attribution of checksum failure stats to the wrong datab
Date
Msg-id E1tyabt-001coo-04@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix mis-attribution of checksum failure stats to the wrong database

Checksum failure stats could be attributed to the wrong database in two cases:

- when a read of a shared relation encountered a checksum error , it would be
  attributed to the current database, instead of the "database" representing
  shared relations

- when using CREATE DATABASE ... STRATEGY WAL_LOG checksum errors in the
  source database would be attributed to the current database

The checksum stats reporting via PageIsVerifiedExtended(PIV_REPORT_STAT) does
not have access to the information about what database a page belongs to.

This fixes the issue by removing PIV_REPORT_STAT and delegating the
responsibility to report stats to the caller, which now can learn about the
number of stats via a new optional argument.

As this changes the signature of PageIsVerifiedExtended() and all callers
should adapt to the new signature, use the occasion to rename the function to
PageIsVerified() and remove the compatibility macro.

We could instead have fixed this by adding information about the database to
the args of PageIsVerified(), but there are soon-to-be-applied patches that
need to separate the stats reporting from the PageIsVerified() call
anyway. Those patches also include testing for the failure paths, something we
inexplicably have not had.

As there is no caller of pgstat_report_checksum_failure() left, remove it.

It'd be possible, but awkward to fix this in the back branches. We considered
doing the work not quite worth it, as mis-attributed stats should still elicit
concern. The emitted error messages do allow to attribute the errors
correctly.

Discussion: https://postgr.es/m/5tyic6epvdlmd6eddgelv47syg2b5cpwffjam54axp25xyq2ga@ptwkinxqo3az
Discussion: https://postgr.es/m/mglpvvbhighzuwudjxzu4br65qqcxsnyvio3nl4fbog3qknwhg@e4gt7npsohuz

Branch
------
master

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

Modified Files
--------------
src/backend/catalog/storage.c                | 16 ++++++++++++++--
src/backend/storage/buffer/bufmgr.c          | 16 +++++++++++++---
src/backend/storage/page/bufpage.c           | 20 +++++++++++++-------
src/backend/utils/activity/pgstat_database.c |  9 ---------
src/include/pgstat.h                         |  1 -
src/include/storage/bufpage.h                | 20 ++++++++------------
6 files changed, 48 insertions(+), 34 deletions(-)


pgsql-committers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: pgsql: pg_upgrade: Fix inconsistency in memory freeing
Next
From: Andres Freund
Date:
Subject: pgsql: aio, bufmgr: Comment fixes/improvements