From 96ef3b8ff1cf1950e897fd2f766d4bd9ef0d5d56 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Fri, 22 Mar 2013 13:54:07 +0000 Subject: Allow I/O reliability checks using 16-bit checksums Checksums are set immediately prior to flush out of shared buffers and checked when pages are read in again. Hint bit setting will require full page write when block is dirtied, which causes various infrastructure changes. Extensive comments, docs and README. WARNING message thrown if checksum fails on non-all zeroes page; ERROR thrown but can be disabled with ignore_checksum_failure = on. Feature enabled by an initdb option, since transition from option off to option on is long and complex and has not yet been implemented. Default is not to use checksums. Checksum used is WAL CRC-32 truncated to 16-bits. Simon Riggs, Jeff Davis, Greg Smith Wide input and assistance from many community members. Thank you. --- src/backend/access/spgist/spginsert.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/backend/access/spgist/spginsert.c') diff --git a/src/backend/access/spgist/spginsert.c b/src/backend/access/spgist/spginsert.c index ac01fd292c1..94384acc485 100644 --- a/src/backend/access/spgist/spginsert.c +++ b/src/backend/access/spgist/spginsert.c @@ -154,6 +154,7 @@ spgbuildempty(PG_FUNCTION_ARGS) SpGistInitMetapage(page); /* Write the page. If archiving/streaming, XLOG it. */ + PageSetChecksumInplace(page, SPGIST_METAPAGE_BLKNO); smgrwrite(index->rd_smgr, INIT_FORKNUM, SPGIST_METAPAGE_BLKNO, (char *) page, true); if (XLogIsNeeded()) @@ -163,6 +164,7 @@ spgbuildempty(PG_FUNCTION_ARGS) /* Likewise for the root page. */ SpGistInitPage(page, SPGIST_LEAF); + PageSetChecksumInplace(page, SPGIST_ROOT_BLKNO); smgrwrite(index->rd_smgr, INIT_FORKNUM, SPGIST_ROOT_BLKNO, (char *) page, true); if (XLogIsNeeded()) @@ -172,6 +174,7 @@ spgbuildempty(PG_FUNCTION_ARGS) /* Likewise for the null-tuples root page. */ SpGistInitPage(page, SPGIST_LEAF | SPGIST_NULLS); + PageSetChecksumInplace(page, SPGIST_NULL_BLKNO); smgrwrite(index->rd_smgr, INIT_FORKNUM, SPGIST_NULL_BLKNO, (char *) page, true); if (XLogIsNeeded()) -- cgit v1.2.3