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

Commit 5c73ae1

Browse files
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.
1 parent 2827516 commit 5c73ae1

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.120 2010/02/26 02:00:34 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.121 2010/03/19 10:41:21 sriggs Exp $
1313
*
1414
* NOTES
1515
* Postgres btree pages look like ordinary relation pages. The opaque
@@ -1301,6 +1301,7 @@ _bt_pagedel(Relation rel, Buffer buf, BTStack stack)
13011301
xlrec.deadblk = target;
13021302
xlrec.leftblk = leftsib;
13031303
xlrec.rightblk = rightsib;
1304+
xlrec.btpo_xact = opaque->btpo.xact;
13041305

13051306
rdata[0].data = (char *) &xlrec;
13061307
rdata[0].len = SizeOfBtreeDeletePage;

src/backend/access/nbtree/nbtxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.62 2010/02/26 02:00:34 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.63 2010/03/19 10:41:22 sriggs Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -729,7 +729,7 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
729729

730730
pageop->btpo_prev = leftsib;
731731
pageop->btpo_next = rightsib;
732-
pageop->btpo.xact = FrozenTransactionId;
732+
pageop->btpo.xact = xlrec->btpo_xact;
733733
pageop->btpo_flags = BTP_DELETED;
734734
pageop->btpo_cycleid = 0;
735735

src/include/access/nbtree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.130 2010/02/26 02:01:21 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.131 2010/03/19 10:41:22 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -375,14 +375,15 @@ typedef struct xl_btree_vacuum
375375
* identifies the tuple removed from the parent page (note that we remove
376376
* this tuple's downlink and the *following* tuple's key). Note we do not
377377
* store any content for the deleted page --- it is just rewritten as empty
378-
* during recovery.
378+
* during recovery, apart from resetting the btpo.xact.
379379
*/
380380
typedef struct xl_btree_delete_page
381381
{
382382
xl_btreetid target; /* deleted tuple id in parent page */
383383
BlockNumber deadblk; /* child block being deleted */
384384
BlockNumber leftblk; /* child block's left sibling, if any */
385385
BlockNumber rightblk; /* child block's right sibling */
386+
TransactionId btpo_xact; /* value of btpo.xact for use in recovery */
386387
/* xl_btree_metadata FOLLOWS IF XLOG_BTREE_DELETE_PAGE_META */
387388
} xl_btree_delete_page;
388389

0 commit comments

Comments
 (0)