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

Commit 69cf853

Browse files
Clear up issue with FSM and oldest bpto.xact.
On further reflection, code comments added by commit b0229f2 slightly misrepresented how we determine the oldest bpto.xact for the index. btvacuumpage() does not treat the bpto.xact of a page that it put in the FSM as a candidate to be the oldest deleted page (the delete-marked page that has the oldest bpto.xact XID among all pages encountered). The definition of a deleted page for the purposes of the bpto.xact calculation is different from the definition used by the bulk delete statistics. The bulk delete statistics don't distinguish between pages that were deleted by the current VACUUM, pages deleted by a previous VACUUM operation but not yet recyclable/reusable, and pages that are reusable (though reusable pages are counted separately). Backpatch: 11-, just like commit b0229f2.
1 parent 4e21f8b commit 69cf853

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/backend/access/nbtree/nbtree.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,6 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
824824
* If any oldest btpo.xact from a previously deleted page in the index
825825
* is older than RecentGlobalXmin, then at least one deleted page can
826826
* be recycled -- don't skip cleanup.
827-
*
828-
* Note that btvacuumpage currently doesn't make any effort to
829-
* recognize when a recycled page is already in the FSM (i.e. put
830-
* there by a previous VACUUM operation). We have to be conservative
831-
* because the FSM isn't crash safe. Hopefully recycled pages get
832-
* reused before too long.
833827
*/
834828
result = true;
835829
}
@@ -1044,15 +1038,6 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
10441038

10451039
MemoryContextDelete(vstate.pagedelcontext);
10461040

1047-
/*
1048-
* Maintain a count of the oldest btpo.xact and current number of heap
1049-
* tuples in the metapage (for the benefit of _bt_vacuum_needs_cleanup).
1050-
* The oldest page is typically a page deleted by a previous VACUUM
1051-
* operation.
1052-
*/
1053-
_bt_update_meta_cleanup_info(rel, vstate.oldestBtpoXact,
1054-
info->num_heap_tuples);
1055-
10561041
/*
10571042
* If we found any recyclable pages (and recorded them in the FSM), then
10581043
* forcibly update the upper-level FSM pages to ensure that searchers can
@@ -1068,6 +1053,21 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
10681053
if (vstate.totFreePages > 0)
10691054
IndexFreeSpaceMapVacuum(rel);
10701055

1056+
/*
1057+
* Maintain the oldest btpo.xact and a count of the current number of heap
1058+
* tuples in the metapage (for the benefit of _bt_vacuum_needs_cleanup).
1059+
*
1060+
* The page with the oldest btpo.xact is typically a page deleted by this
1061+
* VACUUM operation, since pages deleted by a previous VACUUM operation
1062+
* tend to be placed in the FSM (by the current VACUUM operation) -- such
1063+
* pages are not candidates to be the oldest btpo.xact. (Note that pages
1064+
* placed in the FSM are reported as deleted pages in the bulk delete
1065+
* statistics, despite not counting as deleted pages for the purposes of
1066+
* determining the oldest btpo.xact.)
1067+
*/
1068+
_bt_update_meta_cleanup_info(rel, vstate.oldestBtpoXact,
1069+
info->num_heap_tuples);
1070+
10711071
/* update statistics */
10721072
stats->num_pages = num_pages;
10731073
stats->pages_free = vstate.totFreePages;

0 commit comments

Comments
 (0)