Skip to content

Instantly share code, notes, and snippets.

@ololobus
Last active April 27, 2022 15:37
Show Gist options
  • Save ololobus/f5739667d0ec249d61ae9e7e4857b624 to your computer and use it in GitHub Desktop.
Save ololobus/f5739667d0ec249d61ae9e7e4857b624 to your computer and use it in GitHub Desktop.
WAL redo checksum
// @@ -569,6 +569,21 @@ PushPage(StringInfo input_message)
/*
* Every backend on the compute side will verify the page checksum
* after reading it from pageserver using GetPage@LSN. Here in the
* WAL redo process we are reading pages directly from stdin, so we
* would better verify checksum too before applying any WAL records
* on top of it.
*/
if (!PageIsVerifiedExtended((Page) content, blknum,
PIV_LOG_WARNING | PIV_REPORT_STAT))
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
errmsg("invalid page in block %u of relation %s",
blknum,
relpathperm(rnode, forknum))));
// @@ -614,6 +629,14 @@ ApplyRecord(StringInfo input_message)
/*
* Validate CRC of the WAL record, because DecodeXLogRecord() doesn not
* check it. It is only validated in the XLogReadRecord(), which we do
* not use.
*/
if (!ValidXLogRecord(&reader_state, record, reader_state.EndRecPtr))
elog(ERROR, "failed to verify WAL record checksum: %s", reader_state.errormsg_buf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment