mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Add WAL consistency checking facility.
When the new GUC wal_consistency_checking is set to a non-empty value, it triggers recording of additional full-page images, which are compared on the standby against the results of applying the WAL record (without regard to those full-page images). Allowable differences such as hints are masked out, and the resulting pages are compared; any difference results in a FATAL error on the standby. Kuntal Ghosh, based on earlier patches by Michael Paquier and Heikki Linnakangas. Extensively reviewed and revised by Michael Paquier and by me, with additional reviews and comments from Amit Kapila, Álvaro Herrera, Simon Riggs, and Peter Eisentraut.
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/bufmask.h"
|
||||
#include "access/gin_private.h"
|
||||
#include "access/xlogutils.h"
|
||||
#include "utils/memutils.h"
|
||||
@ -758,3 +759,34 @@ gin_xlog_cleanup(void)
|
||||
MemoryContextDelete(opCtx);
|
||||
opCtx = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mask a GIN page before running consistency checks on it.
|
||||
*/
|
||||
void
|
||||
gin_mask(char *pagedata, BlockNumber blkno)
|
||||
{
|
||||
Page page = (Page) pagedata;
|
||||
GinPageOpaque opaque;
|
||||
|
||||
mask_page_lsn(page);
|
||||
opaque = GinPageGetOpaque(page);
|
||||
|
||||
mask_page_hint_bits(page);
|
||||
|
||||
/*
|
||||
* GIN metapage doesn't use pd_lower/pd_upper. Other page types do. Hence,
|
||||
* we need to apply masking for those pages.
|
||||
*/
|
||||
if (opaque->flags != GIN_META)
|
||||
{
|
||||
/*
|
||||
* For GIN_DELETED page, the page is initialized to empty. Hence, mask
|
||||
* the page content.
|
||||
*/
|
||||
if (opaque->flags & GIN_DELETED)
|
||||
mask_page_content(page);
|
||||
else
|
||||
mask_unused_space(page);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user