mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -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))
|
||||
{
|
||||
|
Reference in New Issue
Block a user