Further reductions in Hot Standby conflict processing. These

come from the realistion that HEAP2_CLEAN records don't
always remove user visible data, so conflict processing for
them can be skipped. Confirm validity using Assert checks,
clarify circumstances under which we log heap_cleanup_info
records. Tuning arises from bug fixing of earlier safety
check failures.
This commit is contained in:
Simon Riggs 2010-04-22 02:15:45 +00:00
parent 95a777c612
commit 781ec6b75d
3 changed files with 14 additions and 11 deletions

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.288 2010/02/26 02:00:33 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.289 2010/04/22 02:15:45 sriggs Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
@ -4106,7 +4106,7 @@ heap_xlog_cleanup_info(XLogRecPtr lsn, XLogRecord *record)
} }
/* /*
* Handles HEAP_CLEAN record type * Handles HEAP2_CLEAN record type
*/ */
static void static void
heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record) heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record)
@ -4126,8 +4126,12 @@ heap_xlog_clean(XLogRecPtr lsn, XLogRecord *record)
/* /*
* We're about to remove tuples. In Hot Standby mode, ensure that there's * We're about to remove tuples. In Hot Standby mode, ensure that there's
* no queries running for which the removed tuples are still visible. * no queries running for which the removed tuples are still visible.
*
* Not all HEAP2_CLEAN records remove tuples with xids, so we only want
* to conflict on the records that cause MVCC failures for user queries.
* If latestRemovedXid is invalid, skip conflict processing.
*/ */
if (InHotStandby) if (InHotStandby && TransactionIdIsValid(xlrec->latestRemovedXid))
ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid, ResolveRecoveryConflictWithSnapshot(xlrec->latestRemovedXid,
xlrec->node); xlrec->node);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.23 2010/04/21 17:20:56 sriggs Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.24 2010/04/22 02:15:45 sriggs Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -236,6 +236,7 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin,
{ {
XLogRecPtr recptr; XLogRecPtr recptr;
Assert(TransactionIdIsValid(prstate.latestRemovedXid));
recptr = log_heap_clean(relation, buffer, recptr = log_heap_clean(relation, buffer,
prstate.redirected, prstate.nredirected, prstate.redirected, prstate.nredirected,
prstate.nowdead, prstate.ndead, prstate.nowdead, prstate.ndead,

View File

@ -29,7 +29,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.134 2010/04/21 19:53:24 sriggs Exp $ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.135 2010/04/22 02:15:45 sriggs Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -274,12 +274,11 @@ vacuum_log_cleanup_info(Relation rel, LVRelStats *vacrelstats)
if (rel->rd_istemp || !XLogIsNeeded()) if (rel->rd_istemp || !XLogIsNeeded())
return; return;
if (vacrelstats->tuples_deleted > 0) /*
{ * No need to write the record at all unless it contains a valid value
Assert(TransactionIdIsValid(vacrelstats->latestRemovedXid)); */
if (TransactionIdIsValid(vacrelstats->latestRemovedXid))
(void) log_heap_cleanup_info(rel->rd_node, vacrelstats->latestRemovedXid); (void) log_heap_cleanup_info(rel->rd_node, vacrelstats->latestRemovedXid);
}
} }
/* /*
@ -687,7 +686,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
* Forget the now-vacuumed tuples, and press on, but be careful * Forget the now-vacuumed tuples, and press on, but be careful
* not to reset latestRemovedXid since we want that value to be valid. * not to reset latestRemovedXid since we want that value to be valid.
*/ */
Assert(TransactionIdIsValid(vacrelstats->latestRemovedXid));
vacrelstats->num_dead_tuples = 0; vacrelstats->num_dead_tuples = 0;
vacuumed_pages++; vacuumed_pages++;
} }