From a804a23e7af0e075b88e7b03bfd9b0f22d2657b2 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Fri, 10 Dec 2010 06:59:33 +0000 Subject: Reduce spurious Hot Standby conflicts from never-visible records. Hot Standby conflicts only with tuples that were visible at some point. So ignore tuples from aborted transactions or for tuples updated/deleted during the inserting transaction when generating the conflict transaction ids. Following detailed analysis and test case by Noah Misch. Original report covered btree delete records, correctly observed by Heikki Linnakangas that this applies to other cases also. Fix covers all sources of cleanup records via common code. Includes additional fix compared to commit on HEAD --- src/backend/access/nbtree/nbtxlog.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/backend/access/nbtree/nbtxlog.c') diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index 32614834753..740986d9e11 100644 --- a/src/backend/access/nbtree/nbtxlog.c +++ b/src/backend/access/nbtree/nbtxlog.c @@ -580,7 +580,6 @@ btree_xlog_delete_get_latestRemovedXid(XLogRecord *record) BlockNumber hblkno; OffsetNumber hoffnum; TransactionId latestRemovedXid = InvalidTransactionId; - TransactionId htupxid = InvalidTransactionId; int i; /* @@ -646,24 +645,16 @@ btree_xlog_delete_get_latestRemovedXid(XLogRecord *record) } /* - * If the heap item has storage, then read the header. Some LP_DEAD - * items may not be accessible, so we ignore them. + * If the heap item has storage, then read the header and use that to + * set latestRemovedXid. + * + * Some LP_DEAD items may not be accessible, so we ignore them. */ if (ItemIdHasStorage(hitemid)) { htuphdr = (HeapTupleHeader) PageGetItem(hpage, hitemid); - /* - * Get the heap tuple's xmin/xmax and ratchet up the - * latestRemovedXid. No need to consider xvac values here. - */ - htupxid = HeapTupleHeaderGetXmin(htuphdr); - if (TransactionIdFollows(htupxid, latestRemovedXid)) - latestRemovedXid = htupxid; - - htupxid = HeapTupleHeaderGetXmax(htuphdr); - if (TransactionIdFollows(htupxid, latestRemovedXid)) - latestRemovedXid = htupxid; + HeapTupleHeaderAdvanceLatestRemovedXid(htuphdr, &latestRemovedXid); } else if (ItemIdIsDead(hitemid)) { -- cgit v1.2.3