Skip to content

Commit 1a44df0

Browse files
committed
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
1 parent c08c98d commit 1a44df0

File tree

11 files changed

+16
-14
lines changed

11 files changed

+16
-14
lines changed

src/backend/access/brin/brin_xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ brin_mask(char *pagedata, BlockNumber blkno)
332332
{
333333
Page page = (Page) pagedata;
334334

335-
mask_page_lsn(page);
335+
mask_page_lsn_and_checksum(page);
336336

337337
mask_page_hint_bits(page);
338338

src/backend/access/common/bufmask.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
* mask_page_lsn
2424
*
2525
* In consistency checks, the LSN of the two pages compared will likely be
26-
* different because of concurrent operations when the WAL is generated
27-
* and the state of the page when WAL is applied.
26+
* different because of concurrent operations when the WAL is generated and
27+
* the state of the page when WAL is applied. Also, mask out checksum as
28+
* masking anything else on page means checksum is not going to match as well.
2829
*/
2930
void
30-
mask_page_lsn(Page page)
31+
mask_page_lsn_and_checksum(Page page)
3132
{
3233
PageHeader phdr = (PageHeader) page;
3334

3435
PageXLogRecPtrSet(phdr->pd_lsn, (uint64) MASK_MARKER);
36+
phdr->pd_checksum = MASK_MARKER;
3537
}
3638

3739
/*

src/backend/access/gin/ginxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ gin_mask(char *pagedata, BlockNumber blkno)
770770
Page page = (Page) pagedata;
771771
GinPageOpaque opaque;
772772

773-
mask_page_lsn(page);
773+
mask_page_lsn_and_checksum(page);
774774
opaque = GinPageGetOpaque(page);
775775

776776
mask_page_hint_bits(page);

src/backend/access/gist/gistxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,14 @@ gist_mask(char *pagedata, BlockNumber blkno)
352352
{
353353
Page page = (Page) pagedata;
354354

355-
mask_page_lsn(page);
355+
mask_page_lsn_and_checksum(page);
356356

357357
mask_page_hint_bits(page);
358358
mask_unused_space(page);
359359

360360
/*
361361
* NSN is nothing but a special purpose LSN. Hence, mask it for the same
362-
* reason as mask_page_lsn.
362+
* reason as mask_page_lsn_and_checksum.
363363
*/
364364
GistPageSetNSN(page, (uint64) MASK_MARKER);
365365

src/backend/access/hash/hash_xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ hash_mask(char *pagedata, BlockNumber blkno)
12631263
HashPageOpaque opaque;
12641264
int pagetype;
12651265

1266-
mask_page_lsn(page);
1266+
mask_page_lsn_and_checksum(page);
12671267

12681268
mask_page_hint_bits(page);
12691269
mask_unused_space(page);

src/backend/access/heap/heapam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9149,7 +9149,7 @@ heap_mask(char *pagedata, BlockNumber blkno)
91499149
Page page = (Page) pagedata;
91509150
OffsetNumber off;
91519151

9152-
mask_page_lsn(page);
9152+
mask_page_lsn_and_checksum(page);
91539153

91549154
mask_page_hint_bits(page);
91559155
mask_unused_space(page);

src/backend/access/nbtree/nbtxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ btree_mask(char *pagedata, BlockNumber blkno)
10401040
Page page = (Page) pagedata;
10411041
BTPageOpaque maskopaq;
10421042

1043-
mask_page_lsn(page);
1043+
mask_page_lsn_and_checksum(page);
10441044

10451045
mask_page_hint_bits(page);
10461046
mask_unused_space(page);

src/backend/access/spgist/spgxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ spg_mask(char *pagedata, BlockNumber blkno)
10341034
{
10351035
Page page = (Page) pagedata;
10361036

1037-
mask_page_lsn(page);
1037+
mask_page_lsn_and_checksum(page);
10381038

10391039
mask_page_hint_bits(page);
10401040

src/backend/access/transam/generic_xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ generic_redo(XLogReaderState *record)
541541
void
542542
generic_mask(char *page, BlockNumber blkno)
543543
{
544-
mask_page_lsn(page);
544+
mask_page_lsn_and_checksum(page);
545545

546546
mask_unused_space(page);
547547
}

src/backend/commands/sequence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ ResetSequenceCaches(void)
19411941
void
19421942
seq_mask(char *page, BlockNumber blkno)
19431943
{
1944-
mask_page_lsn(page);
1944+
mask_page_lsn_and_checksum(page);
19451945

19461946
mask_unused_space(page);
19471947
}

src/include/access/bufmask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/* Marker used to mask pages consistently */
2424
#define MASK_MARKER 0
2525

26-
extern void mask_page_lsn(Page page);
26+
extern void mask_page_lsn_and_checksum(Page page);
2727
extern void mask_page_hint_bits(Page page);
2828
extern void mask_unused_space(Page page);
2929
extern void mask_lp_flags(Page page);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy