Fix replay of XLOG_HEAP_NEWPAGE WAL records to pay attention to the forknum
field of the WAL record. The previous coding always wrote to the main fork, resulting in data corruption if the page was meant to go into a non-default fork. At present, the only operation that can produce such WAL records is ALTER TABLE/INDEX SET TABLESPACE when executed with archive_mode = on. Data corruption would be observed on standby slaves, and could occur on the master as well if a database crash and recovery occurred after committing the ALTER and before the next checkpoint. Per report from Gordon Shannon. Back-patch to 8.4; the problem doesn't exist in earlier branches because we didn't have a concept of multiple relation forks then.
This commit is contained in:
parent
3d94d77159
commit
62938d6cc8
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.277.2.1 2009/08/24 02:18:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.277.2.2 2010/05/02 22:28:11 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -4195,8 +4195,10 @@ heap_xlog_newpage(XLogRecPtr lsn, XLogRecord *record)
|
||||
* Note: the NEWPAGE log record is used for both heaps and indexes, so do
|
||||
* not do anything that assumes we are touching a heap.
|
||||
*/
|
||||
buffer = XLogReadBuffer(xlrec->node, xlrec->blkno, true);
|
||||
buffer = XLogReadBufferExtended(xlrec->node, xlrec->forknum, xlrec->blkno,
|
||||
RBM_ZERO);
|
||||
Assert(BufferIsValid(buffer));
|
||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
page = (Page) BufferGetPage(buffer);
|
||||
|
||||
Assert(record->xl_len == SizeOfHeapNewpage + BLCKSZ);
|
||||
|
Loading…
x
Reference in New Issue
Block a user