Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7dc7218

Browse files
committed
Don't call PageGetSpecialPointer() on page until it's been initialized.
After calling XLogInitBufferForRedo(), the page might be all-zeros if it was not in page cache already. btree_xlog_unlink_page initialized the page correctly, but it called PageGetSpecialPointer before initializing it, which would lead to a corrupt page at WAL replay, if the unlinked page is not in page cache. Backpatch to 9.4, the bug came with the rewrite of B-tree page deletion.
1 parent 1afc1fe commit 7dc7218

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/access/nbtree/nbtxlog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,10 @@ btree_xlog_unlink_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
997997
buffer = XLogReadBuffer(xlrec->node, xlrec->leafblk, true);
998998
Assert(BufferIsValid(buffer));
999999
page = (Page) BufferGetPage(buffer);
1000-
pageop = (BTPageOpaque) PageGetSpecialPointer(page);
10011000

10021001
_bt_pageinit(page, BufferGetPageSize(buffer));
1002+
pageop = (BTPageOpaque) PageGetSpecialPointer(page);
1003+
10031004
pageop->btpo_flags = BTP_HALF_DEAD | BTP_LEAF;
10041005
pageop->btpo_prev = xlrec->leafleftsib;
10051006
pageop->btpo_next = xlrec->leafrightsib;

0 commit comments

Comments
 (0)