mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-08 21:39:20 +02:00
Clear up issue with FSM and oldest bpto.xact.
On further reflection, code comments added by commitb0229f26
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 commitb0229f26
.
This commit is contained in:
parent
40708eaaf3
commit
e1477db921
@ -818,12 +818,6 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
|
|||||||
* If any oldest btpo.xact from a previously deleted page in the index
|
* If any oldest btpo.xact from a previously deleted page in the index
|
||||||
* is older than RecentGlobalXmin, then at least one deleted page can
|
* is older than RecentGlobalXmin, then at least one deleted page can
|
||||||
* be recycled -- don't skip cleanup.
|
* be recycled -- don't skip cleanup.
|
||||||
*
|
|
||||||
* Note that btvacuumpage currently doesn't make any effort to
|
|
||||||
* recognize when a recycled page is already in the FSM (i.e. put
|
|
||||||
* there by a previous VACUUM operation). We have to be conservative
|
|
||||||
* because the FSM isn't crash safe. Hopefully recycled pages get
|
|
||||||
* reused before too long.
|
|
||||||
*/
|
*/
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
@ -1073,15 +1067,6 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
|
|||||||
|
|
||||||
MemoryContextDelete(vstate.pagedelcontext);
|
MemoryContextDelete(vstate.pagedelcontext);
|
||||||
|
|
||||||
/*
|
|
||||||
* Maintain a count of the oldest btpo.xact and current number of heap
|
|
||||||
* tuples in the metapage (for the benefit of _bt_vacuum_needs_cleanup).
|
|
||||||
* The oldest page is typically a page deleted by a previous VACUUM
|
|
||||||
* operation.
|
|
||||||
*/
|
|
||||||
_bt_update_meta_cleanup_info(rel, vstate.oldestBtpoXact,
|
|
||||||
info->num_heap_tuples);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we found any recyclable pages (and recorded them in the FSM), then
|
* If we found any recyclable pages (and recorded them in the FSM), then
|
||||||
* forcibly update the upper-level FSM pages to ensure that searchers can
|
* forcibly update the upper-level FSM pages to ensure that searchers can
|
||||||
@ -1097,6 +1082,21 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
|
|||||||
if (vstate.totFreePages > 0)
|
if (vstate.totFreePages > 0)
|
||||||
IndexFreeSpaceMapVacuum(rel);
|
IndexFreeSpaceMapVacuum(rel);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maintain the oldest btpo.xact and a count of the current number of heap
|
||||||
|
* tuples in the metapage (for the benefit of _bt_vacuum_needs_cleanup).
|
||||||
|
*
|
||||||
|
* The page with the oldest btpo.xact is typically a page deleted by this
|
||||||
|
* VACUUM operation, since pages deleted by a previous VACUUM operation
|
||||||
|
* tend to be placed in the FSM (by the current VACUUM operation) -- such
|
||||||
|
* pages are not candidates to be the oldest btpo.xact. (Note that pages
|
||||||
|
* placed in the FSM are reported as deleted pages in the bulk delete
|
||||||
|
* statistics, despite not counting as deleted pages for the purposes of
|
||||||
|
* determining the oldest btpo.xact.)
|
||||||
|
*/
|
||||||
|
_bt_update_meta_cleanup_info(rel, vstate.oldestBtpoXact,
|
||||||
|
info->num_heap_tuples);
|
||||||
|
|
||||||
/* update statistics */
|
/* update statistics */
|
||||||
stats->num_pages = num_pages;
|
stats->num_pages = num_pages;
|
||||||
stats->pages_free = vstate.totFreePages;
|
stats->pages_free = vstate.totFreePages;
|
||||||
|
Loading…
Reference in New Issue
Block a user