Skip to content

Commit 7dca975

Browse files
committed
Add a comment about why we always replay backup blocks from WAL.
1 parent fd62065 commit 7dca975

File tree

1 file changed

+10
-1
lines changed
  • src/backend/access/transam

1 file changed

+10
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.156 2004/08/04 21:33:46 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.157 2004/08/08 03:22:08 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2187,6 +2187,15 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
21872187
* Restore the backup blocks present in an XLOG record, if any.
21882188
*
21892189
* We assume all of the record has been read into memory at *record.
2190+
*
2191+
* Note: when a backup block is available in XLOG, we restore it
2192+
* unconditionally, even if the page in the database appears newer.
2193+
* This is to protect ourselves against database pages that were partially
2194+
* or incorrectly written during a crash. We assume that the XLOG data
2195+
* must be good because it has passed a CRC check, while the database
2196+
* page might not be. This will force us to replay all subsequent
2197+
* modifications of the page that appear in XLOG, rather than possibly
2198+
* ignoring them as already applied, but that's not a huge drawback.
21902199
*/
21912200
static void
21922201
RestoreBkpBlocks(XLogRecord *record, XLogRecPtr lsn)

0 commit comments

Comments
 (0)