summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtxlog.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2010-12-10 06:59:33 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2010-12-10 06:59:33 +0000
commita804a23e7af0e075b88e7b03bfd9b0f22d2657b2 (patch)
tree28751576fe1838881a15885703ab649cddaed171 /src/backend/access/nbtree/nbtxlog.c
parent2ffcb0cb6a5bf97de22f0ce58f55537ce1c87653 (diff)
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
Diffstat (limited to 'src/backend/access/nbtree/nbtxlog.c')
-rw-r--r--src/backend/access/nbtree/nbtxlog.c19
1 files changed, 5 insertions, 14 deletions
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))
{