aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-05-02 23:18:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-05-02 23:18:03 +0000
commit8c3cc86e7b688b0efe5ec6ce4f4342c2883b1db5 (patch)
tree33cfc93810e9c15988c7dc26f7350a6b9d5d4c53 /src/backend/access/transam/xlogutils.c
parent8ec943856a4e94637600fa7cad976281ca3f4071 (diff)
downloadpostgresql-8c3cc86e7b688b0efe5ec6ce4f4342c2883b1db5.tar.gz
postgresql-8c3cc86e7b688b0efe5ec6ce4f4342c2883b1db5.zip
During WAL recovery, when reading a page that we intend to overwrite completely
from the WAL data, don't bother to physically read it; just have bufmgr.c return a zeroed-out buffer instead. This speeds recovery significantly, and also avoids unnecessary failures when a page-to-be-overwritten has corrupt page headers on disk. This replaces a former kluge that accomplished the latter by pretending zero_damaged_pages was always ON during WAL recovery; which was OK when the kluge was put in, but is unsafe when restoring a WAL log that was written with full_page_writes off. Heikki Linnakangas
Diffstat (limited to 'src/backend/access/transam/xlogutils.c')
-rw-r--r--src/backend/access/transam/xlogutils.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index a433ad9fca7..39c3269bc11 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.49 2007/01/05 22:19:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.50 2007/05/02 23:18:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -206,7 +206,9 @@ XLogCheckInvalidPages(void)
* If "init" is true then the caller intends to rewrite the page fully
* using the info in the XLOG record. In this case we will extend the
* relation if needed to make the page exist, and we will not complain about
- * the page being "new" (all zeroes).
+ * the page being "new" (all zeroes); in fact, we usually will supply a
+ * zeroed buffer without reading the page at all, so as to avoid unnecessary
+ * failure if the page is present on disk but has corrupt headers.
*
* If "init" is false then the caller needs the page to be valid already.
* If the page doesn't exist or contains zeroes, we return InvalidBuffer.
@@ -226,7 +228,10 @@ XLogReadBuffer(Relation reln, BlockNumber blkno, bool init)
if (blkno < lastblock)
{
/* page exists in file */
- buffer = ReadBuffer(reln, blkno);
+ if (init)
+ buffer = ReadOrZeroBuffer(reln, blkno);
+ else
+ buffer = ReadBuffer(reln, blkno);
}
else
{