summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtpage.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-02-21 15:04:01 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-02-21 15:04:01 -0500
commit2c293f25494f2d465bcff49d7aab6ec06a40e436 (patch)
tree0bc003ffc19c5a9576fb8a4c9ee61fb398e0f97a /src/backend/access/nbtree/nbtpage.c
parentf3ad4ca00e1f63357751d855a9150d3ba404a2b2 (diff)
Don't clear btpo_cycleid during _bt_vacuum_one_page.
When "vacuuming" a single btree page by removing LP_DEAD tuples, we are not actually within a vacuum operation, but rather in an ordinary insertion process that could well be running concurrently with a vacuum. So clearing the cycleid is incorrect, and could cause the concurrent vacuum to miss removing tuples that it needs to remove. This is a longstanding bug introduced by commit e6284649b9e30372b3990107a082bc7520325676 of 2006-07-25. I believe it explains Maxim Boguk's recent report of index corruption, and probably some other previously unexplained reports. In 9.0 and up this is a one-line fix; before that we need to introduce a flag to tell _bt_delitems what to do.
Diffstat (limited to 'src/backend/access/nbtree/nbtpage.c')
-rw-r--r--src/backend/access/nbtree/nbtpage.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index d1a49633936..a89e3ba84f4 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -650,7 +650,8 @@ _bt_page_recyclable(Page page)
*/
void
_bt_delitems(Relation rel, Buffer buf,
- OffsetNumber *itemnos, int nitems)
+ OffsetNumber *itemnos, int nitems,
+ bool inVacuum)
{
Page page = BufferGetPage(buf);
BTPageOpaque opaque;
@@ -662,11 +663,12 @@ _bt_delitems(Relation rel, Buffer buf,
PageIndexMultiDelete(page, itemnos, nitems);
/*
- * We can clear the vacuum cycle ID since this page has certainly been
- * processed by the current vacuum scan.
+ * If this is within VACUUM, we can clear the vacuum cycle ID since this
+ * page has certainly been processed by the current vacuum scan.
*/
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
- opaque->btpo_cycleid = 0;
+ if (inVacuum)
+ opaque->btpo_cycleid = 0;
/*
* Mark the page as not containing any LP_DEAD items. This is not