Commit 5c73ae17 authored by Simon Riggs's avatar Simon Riggs

Reset btpo.xact following recovery of btree delete page. Add btpo_xact

field into WAL record and reset it from there, rather than using
FrozenTransactionId which can lead to some corner case bugs.

Problem report and suggested route to a fix from Heikki, details by me.
parent 28275163
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.120 2010/02/26 02:00:34 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.121 2010/03/19 10:41:21 sriggs Exp $
* *
* NOTES * NOTES
* Postgres btree pages look like ordinary relation pages. The opaque * Postgres btree pages look like ordinary relation pages. The opaque
...@@ -1301,6 +1301,7 @@ _bt_pagedel(Relation rel, Buffer buf, BTStack stack) ...@@ -1301,6 +1301,7 @@ _bt_pagedel(Relation rel, Buffer buf, BTStack stack)
xlrec.deadblk = target; xlrec.deadblk = target;
xlrec.leftblk = leftsib; xlrec.leftblk = leftsib;
xlrec.rightblk = rightsib; xlrec.rightblk = rightsib;
xlrec.btpo_xact = opaque->btpo.xact;
rdata[0].data = (char *) &xlrec; rdata[0].data = (char *) &xlrec;
rdata[0].len = SizeOfBtreeDeletePage; rdata[0].len = SizeOfBtreeDeletePage;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.62 2010/02/26 02:00:34 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.63 2010/03/19 10:41:22 sriggs Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -729,7 +729,7 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record) ...@@ -729,7 +729,7 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
pageop->btpo_prev = leftsib; pageop->btpo_prev = leftsib;
pageop->btpo_next = rightsib; pageop->btpo_next = rightsib;
pageop->btpo.xact = FrozenTransactionId; pageop->btpo.xact = xlrec->btpo_xact;
pageop->btpo_flags = BTP_DELETED; pageop->btpo_flags = BTP_DELETED;
pageop->btpo_cycleid = 0; pageop->btpo_cycleid = 0;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.130 2010/02/26 02:01:21 momjian Exp $ * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.131 2010/03/19 10:41:22 sriggs Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -375,7 +375,7 @@ typedef struct xl_btree_vacuum ...@@ -375,7 +375,7 @@ typedef struct xl_btree_vacuum
* identifies the tuple removed from the parent page (note that we remove * identifies the tuple removed from the parent page (note that we remove
* this tuple's downlink and the *following* tuple's key). Note we do not * this tuple's downlink and the *following* tuple's key). Note we do not
* store any content for the deleted page --- it is just rewritten as empty * store any content for the deleted page --- it is just rewritten as empty
* during recovery. * during recovery, apart from resetting the btpo.xact.
*/ */
typedef struct xl_btree_delete_page typedef struct xl_btree_delete_page
{ {
...@@ -383,6 +383,7 @@ typedef struct xl_btree_delete_page ...@@ -383,6 +383,7 @@ typedef struct xl_btree_delete_page
BlockNumber deadblk; /* child block being deleted */ BlockNumber deadblk; /* child block being deleted */
BlockNumber leftblk; /* child block's left sibling, if any */ BlockNumber leftblk; /* child block's left sibling, if any */
BlockNumber rightblk; /* child block's right sibling */ BlockNumber rightblk; /* child block's right sibling */
TransactionId btpo_xact; /* value of btpo.xact for use in recovery */
/* xl_btree_metadata FOLLOWS IF XLOG_BTREE_DELETE_PAGE_META */ /* xl_btree_metadata FOLLOWS IF XLOG_BTREE_DELETE_PAGE_META */
} xl_btree_delete_page; } xl_btree_delete_page;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment