aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2011-06-16 10:17:59 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2011-06-16 10:17:59 +0100
commit9340e643e4cbc11a7a5aaea0297236e9a8c07600 (patch)
treea074610a26b840475502603a62b0c5e49eb5d12c /src
parenta969a2f03041cd33bc9f9f75f0b6a1c0f5b921e2 (diff)
downloadpostgresql-9340e643e4cbc11a7a5aaea0297236e9a8c07600.tar.gz
postgresql-9340e643e4cbc11a7a5aaea0297236e9a8c07600.zip
Respect Hot Standby controls while recycling btree index pages.
Btree pages were recycled after VACUUM deletes all records on a page and then a subsequent VACUUM occurs after the RecentXmin horizon is reached. Using RecentXmin meant that we did not respond correctly to the user controls provide to avoid Hot Standby conflicts and so spurious conflicts could be generated in some workload combinations. We now reuse pages only when we reach RecentGlobalXmin, which can be much later in the presence of long running queries and is also controlled by vacuum_defer_cleanup_age and hot_standby_feedback. Noah Misch and Simon Riggs
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/nbtree/nbtpage.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 58f47e7b646..65354e6d28f 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -677,6 +677,7 @@ bool
_bt_page_recyclable(Page page)
{
BTPageOpaque opaque;
+ TransactionId cutoff;
/*
* It's possible to find an all-zeroes page in an index --- for example, a
@@ -689,11 +690,18 @@ _bt_page_recyclable(Page page)
/*
* Otherwise, recycle if deleted and too old to have any processes
- * interested in it.
+ * interested in it. If we are generating records for Hot Standby
+ * defer page recycling until RecentGlobalXmin to respect user
+ * controls specified by vacuum_defer_cleanup_age or hot_standby_feedback.
*/
+ if (XLogStandbyInfoActive())
+ cutoff = RecentGlobalXmin;
+ else
+ cutoff = RecentXmin;
+
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
if (P_ISDELETED(opaque) &&
- TransactionIdPrecedesOrEquals(opaque->btpo.xact, RecentXmin))
+ TransactionIdPrecedesOrEquals(opaque->btpo.xact, cutoff))
return true;
return false;
}