bt_recycle_offby1.v1.patch

application/octet-stream

Filename: bt_recycle_offby1.v1.patch
Type: application/octet-stream
Part: 0
Message: Re: On-the-fly index tuple deletion vs. hot_standby
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 65354e6..7443298 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -560,9 +560,18 @@ _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 = TransactionIdRetreat(opaque->btpo.xact);
+
+						_bt_log_reuse_page(rel, blkno, latestRemovedXid);
 					}
 
 					/* Okay to use page.  Re-initialize and return it */