diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-02-21 15:03:44 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-02-21 15:03:44 -0500 |
commit | 6182e01f18f71c48915e2aebb20362294de6e677 (patch) | |
tree | 0d52f64f18411716f478902d6417e319d9402924 | |
parent | 3d2aa2c086116fd41dc7f8cff1e3ec9e5d4e2b2c (diff) | |
download | postgresql-6182e01f18f71c48915e2aebb20362294de6e677.tar.gz |
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.
-rw-r--r-- | src/backend/access/nbtree/nbtpage.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 4b1a2e912b..9e34436244 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -829,11 +829,9 @@ _bt_delitems_delete(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. + * Unlike _bt_delitems_vacuum, we *must not* clear the vacuum cycle ID, + * because this is not called by VACUUM. */ - opaque = (BTPageOpaque) PageGetSpecialPointer(page); - opaque->btpo_cycleid = 0; /* * Mark the page as not containing any LP_DEAD items. This is not @@ -842,6 +840,7 @@ _bt_delitems_delete(Relation rel, Buffer buf, * true and it doesn't seem worth an additional page scan to check it. * Remember that BTP_HAS_GARBAGE is only a hint anyway. */ + opaque = (BTPageOpaque) PageGetSpecialPointer(page); opaque->btpo_flags &= ~BTP_HAS_GARBAGE; MarkBufferDirty(buf); |