diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-02-08 15:45:30 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-02-08 15:45:30 -0500 |
commit | a507b86900f695aacc8d52b7d2cfcb65f58862a2 (patch) | |
tree | 1cc25aaddb8613d2744e803e3ea970fd50d1e309 /src/backend/access/gist/gistxlog.c | |
parent | 115cb31597fac8a17202d1e41da8baf33fcb60cf (diff) | |
download | postgresql-a507b86900f695aacc8d52b7d2cfcb65f58862a2.tar.gz postgresql-a507b86900f695aacc8d52b7d2cfcb65f58862a2.zip |
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.
Diffstat (limited to 'src/backend/access/gist/gistxlog.c')
-rw-r--r-- | src/backend/access/gist/gistxlog.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c index 88b97a4e487..cbda9e705cc 100644 --- a/src/backend/access/gist/gistxlog.c +++ b/src/backend/access/gist/gistxlog.c @@ -13,6 +13,7 @@ */ #include "postgres.h" +#include "access/bufmask.h" #include "access/gist_private.h" #include "access/xloginsert.h" #include "access/xlogutils.h" @@ -343,6 +344,48 @@ gist_xlog_cleanup(void) } /* + * Mask a Gist page before running consistency checks on it. + */ +void +gist_mask(char *pagedata, BlockNumber blkno) +{ + Page page = (Page) pagedata; + + mask_page_lsn(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. + */ + GistPageSetNSN(page, (uint64) MASK_MARKER); + + /* + * We update F_FOLLOW_RIGHT flag on the left child after writing WAL + * record. Hence, mask this flag. See gistplacetopage() for details. + */ + GistMarkFollowRight(page); + + if (GistPageIsLeaf(page)) + { + /* + * In gist leaf pages, it is possible to modify the LP_FLAGS without + * emitting any WAL record. Hence, mask the line pointer flags. See + * gistkillitems() for details. + */ + mask_lp_flags(page); + } + + /* + * During gist redo, we never mark a page as garbage. Hence, mask it to + * ignore any differences. + */ + GistClearPageHasGarbage(page); +} + +/* * Write WAL record of a page split. */ XLogRecPtr |