mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Extend PageIsVerified() to handle more custom options
This is useful for checks of relation pages without having to load the pages into the shared buffers, and two cases can make use of that: page verification in base backups and the online, lock-safe, flavor. Compatibility is kept with past versions using a macro that calls the new extended routine with the set of options compatible with the original version. Extracted from a larger patch by the same author. Author: Anastasia Lubennikova Reviewed-by: Michael Paquier, Julien Rouhaud Discussion: https://postgr.es/m/608f3476-0598-2514-2c03-e05c7d2b0cbd@postgrespro.ru
This commit is contained in:
@@ -61,7 +61,7 @@ PageInit(Page page, Size pageSize, Size specialSize)
|
||||
|
||||
|
||||
/*
|
||||
* PageIsVerified
|
||||
* PageIsVerifiedExtended
|
||||
* Check that the page header and checksum (if any) appear valid.
|
||||
*
|
||||
* This is called when a page has just been read in from disk. The idea is
|
||||
@@ -77,9 +77,15 @@ PageInit(Page page, Size pageSize, Size specialSize)
|
||||
* allow zeroed pages here, and are careful that the page access macros
|
||||
* treat such a page as empty and without free space. Eventually, VACUUM
|
||||
* will clean up such a page and make it usable.
|
||||
*
|
||||
* If flag PIV_LOG_WARNING is set, a WARNING is logged in the event of
|
||||
* a checksum failure.
|
||||
*
|
||||
* If flag PIV_REPORT_STAT is set, a checksum failure is reported directly
|
||||
* to pgstat.
|
||||
*/
|
||||
bool
|
||||
PageIsVerified(Page page, BlockNumber blkno)
|
||||
PageIsVerifiedExtended(Page page, BlockNumber blkno, int flags)
|
||||
{
|
||||
PageHeader p = (PageHeader) page;
|
||||
size_t *pagebytes;
|
||||
@@ -140,12 +146,14 @@ PageIsVerified(Page page, BlockNumber blkno)
|
||||
*/
|
||||
if (checksum_failure)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg("page verification failed, calculated checksum %u but expected %u",
|
||||
checksum, p->pd_checksum)));
|
||||
if ((flags & PIV_LOG_WARNING) != 0)
|
||||
ereport(WARNING,
|
||||
(errcode(ERRCODE_DATA_CORRUPTED),
|
||||
errmsg("page verification failed, calculated checksum %u but expected %u",
|
||||
checksum, p->pd_checksum)));
|
||||
|
||||
pgstat_report_checksum_failure();
|
||||
if ((flags & PIV_REPORT_STAT) != 0)
|
||||
pgstat_report_checksum_failure();
|
||||
|
||||
if (header_sane && ignore_checksum_failure)
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user