For wal_consistency_checking, mask page checksum as well as page LSN.

If the LSN is different, the checksum will be different, too.

Ashwin Agrawal, reviewed by Michael Paquier and Kuntal Ghosh

Discussion: http://postgr.es/m/CALfoeis5iqrAU-+JAN+ZzXkpPr7+-0OAGv7QUHwFn=-wDy4o4Q@mail.gmail.com
This commit is contained in:
Robert Haas 2017-09-22 14:28:22 -04:00
parent 7c75ef5715
commit 6a2fa09c0c
11 changed files with 16 additions and 14 deletions

View File

@ -332,7 +332,7 @@ brin_mask(char *pagedata, BlockNumber blkno)
{
Page page = (Page) pagedata;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);

View File

@ -23,15 +23,17 @@
* mask_page_lsn
*
* In consistency checks, the LSN of the two pages compared will likely be
* different because of concurrent operations when the WAL is generated
* and the state of the page when WAL is applied.
* different because of concurrent operations when the WAL is generated and
* the state of the page when WAL is applied. Also, mask out checksum as
* masking anything else on page means checksum is not going to match as well.
*/
void
mask_page_lsn(Page page)
mask_page_lsn_and_checksum(Page page)
{
PageHeader phdr = (PageHeader) page;
PageXLogRecPtrSet(phdr->pd_lsn, (uint64) MASK_MARKER);
phdr->pd_checksum = MASK_MARKER;
}
/*

View File

@ -770,7 +770,7 @@ gin_mask(char *pagedata, BlockNumber blkno)
Page page = (Page) pagedata;
GinPageOpaque opaque;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
opaque = GinPageGetOpaque(page);
mask_page_hint_bits(page);

View File

@ -352,14 +352,14 @@ gist_mask(char *pagedata, BlockNumber blkno)
{
Page page = (Page) pagedata;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);
mask_unused_space(page);
/*
* NSN is nothing but a special purpose LSN. Hence, mask it for the same
* reason as mask_page_lsn.
* reason as mask_page_lsn_and_checksum.
*/
GistPageSetNSN(page, (uint64) MASK_MARKER);

View File

@ -1263,7 +1263,7 @@ hash_mask(char *pagedata, BlockNumber blkno)
HashPageOpaque opaque;
int pagetype;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);
mask_unused_space(page);

View File

@ -9166,7 +9166,7 @@ heap_mask(char *pagedata, BlockNumber blkno)
Page page = (Page) pagedata;
OffsetNumber off;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);
mask_unused_space(page);

View File

@ -1034,7 +1034,7 @@ btree_mask(char *pagedata, BlockNumber blkno)
Page page = (Page) pagedata;
BTPageOpaque maskopaq;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);
mask_unused_space(page);

View File

@ -1034,7 +1034,7 @@ spg_mask(char *pagedata, BlockNumber blkno)
{
Page page = (Page) pagedata;
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_page_hint_bits(page);

View File

@ -541,7 +541,7 @@ generic_redo(XLogReaderState *record)
void
generic_mask(char *page, BlockNumber blkno)
{
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_unused_space(page);
}

View File

@ -1941,7 +1941,7 @@ ResetSequenceCaches(void)
void
seq_mask(char *page, BlockNumber blkno)
{
mask_page_lsn(page);
mask_page_lsn_and_checksum(page);
mask_unused_space(page);
}

View File

@ -23,7 +23,7 @@
/* Marker used to mask pages consistently */
#define MASK_MARKER 0
extern void mask_page_lsn(Page page);
extern void mask_page_lsn_and_checksum(Page page);
extern void mask_page_hint_bits(Page page);
extern void mask_unused_space(Page page);
extern void mask_lp_flags(Page page);