Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdf2885

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 b48ecf8 commit fdf2885

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
@@ -864,9 +864,10 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
864864

865865
buffer = XLogInitBufferForRedo(record, 3);
866866
page = (Page) BufferGetPage(buffer);
867-
pageop = (BTPageOpaque) PageGetSpecialPointer(page);
868867

869868
_bt_pageinit(page, BufferGetPageSize(buffer));
869+
pageop = (BTPageOpaque) PageGetSpecialPointer(page);
870+
870871
pageop->btpo_flags = BTP_HALF_DEAD | BTP_LEAF;
871872
pageop->btpo_prev = xlrec->leafleftsib;
872873
pageop->btpo_next = xlrec->leafrightsib;

0 commit comments

Comments
 (0)