Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 593a963

Browse files
committed
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 e628464 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.
1 parent 9789c99 commit 593a963

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/backend/access/nbtree/nbtpage.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,9 @@ _bt_delitems_delete(Relation rel, Buffer buf,
841841
PageIndexMultiDelete(page, itemnos, nitems);
842842

843843
/*
844-
* We can clear the vacuum cycle ID since this page has certainly been
845-
* processed by the current vacuum scan.
844+
* Unlike _bt_delitems_vacuum, we *must not* clear the vacuum cycle ID,
845+
* because this is not called by VACUUM.
846846
*/
847-
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
848-
opaque->btpo_cycleid = 0;
849847

850848
/*
851849
* Mark the page as not containing any LP_DEAD items. This is not
@@ -854,6 +852,7 @@ _bt_delitems_delete(Relation rel, Buffer buf,
854852
* true and it doesn't seem worth an additional page scan to check it.
855853
* Remember that BTP_HAS_GARBAGE is only a hint anyway.
856854
*/
855+
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
857856
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
858857

859858
MarkBufferDirty(buf);

0 commit comments

Comments
 (0)