diff options
| author | Simon Riggs <simon@2ndQuadrant.com> | 2011-06-27 22:15:46 +0100 | 
|---|---|---|
| committer | Simon Riggs <simon@2ndQuadrant.com> | 2011-06-27 22:15:46 +0100 | 
| commit | 5cd81b8df0a9f3e4cb407e815b9a789138fd0356 (patch) | |
| tree | 142254f0a9e6f89d6f9dfdd0515b6de91d98db1f /src/backend/access/nbtree/nbtpage.c | |
| parent | 3a2906545f839aaf3a49f08a6f8d2cb1f841168f (diff) | |
Reduce impact of btree page reuse on Hot Standby by fixing off-by-1 error.
WAL records of type XLOG_BTREE_REUSE_PAGE were generated using a
latestRemovedXid one higher than actually needed because xid used was
page opaque->btpo.xact rather than an actually removed xid.
Noticed on an otherwise quiet system by Noah Misch.
Noah Misch and Simon Riggs
Diffstat (limited to 'src/backend/access/nbtree/nbtpage.c')
| -rw-r--r-- | src/backend/access/nbtree/nbtpage.c | 12 | 
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 4ecad196d45..f55ad557932 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -560,9 +560,19 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)  					 */  					if (XLogStandbyInfoActive())  					{ +						TransactionId latestRemovedXid; +  						BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page); -						_bt_log_reuse_page(rel, blkno, opaque->btpo.xact); +						/* +						 * opaque->btpo.xact is the threshold value not the +						 * value to measure conflicts against. We must retreat +						 * by one from it to get the correct conflict xid. +						 */ +						latestRemovedXid = opaque->btpo.xact; +						TransactionIdRetreat(latestRemovedXid); + +						_bt_log_reuse_page(rel, blkno, latestRemovedXid);  					}  					/* Okay to use page.  Re-initialize and return it */  | 
