Skip to content

Commit e1cd66f

Browse files
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
1 parent 9abbed0 commit e1cd66f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,19 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
560560
*/
561561
if (XLogStandbyInfoActive())
562562
{
563+
TransactionId latestRemovedXid;
564+
563565
BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);
564566

565-
_bt_log_reuse_page(rel, blkno, opaque->btpo.xact);
567+
/*
568+
* opaque->btpo.xact is the threshold value not the
569+
* value to measure conflicts against. We must retreat
570+
* by one from it to get the correct conflict xid.
571+
*/
572+
latestRemovedXid = opaque->btpo.xact;
573+
TransactionIdRetreat(latestRemovedXid);
574+
575+
_bt_log_reuse_page(rel, blkno, latestRemovedXid);
566576
}
567577

568578
/* Okay to use page. Re-initialize and return it */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy