Skip to content

Commit e370f10

Browse files
vacuumlazy.c: Standardize rel_pages terminology.
VACUUM's rel_pages field indicates the size of the target heap rel just after the table_relation_vacuum() operation began. There are specific expectations around how rel_pages can be related to other nearby state. In particular, the range of rel_pages must contain every tuple in the relation whose tuple headers might contain an XID < OldestXmin. Consistently refer to the field as rel_pages to make this clearer and more discoverable. This is follow-up work to commit 73f6ec3 from earlier today. Author: Peter Geoghegan <pg@bowt.ie> Reviewed-By: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20220311031351.sbge5m2bpvy2ttxg@alap3.anarazel.de
1 parent 73f6ec3 commit e370f10

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static void
825825
lazy_scan_heap(LVRelState *vacrel, int nworkers)
826826
{
827827
VacDeadItems *dead_items;
828-
BlockNumber nblocks = vacrel->rel_pages,
828+
BlockNumber rel_pages = vacrel->rel_pages,
829829
blkno,
830830
next_unskippable_block,
831831
next_failsafe_block,
@@ -858,7 +858,7 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
858858

859859
/* Report that we're scanning the heap, advertising total # of blocks */
860860
initprog_val[0] = PROGRESS_VACUUM_PHASE_SCAN_HEAP;
861-
initprog_val[1] = nblocks;
861+
initprog_val[1] = rel_pages;
862862
initprog_val[2] = dead_items->max_items;
863863
pgstat_progress_update_multi_param(3, initprog_index, initprog_val);
864864

@@ -882,9 +882,9 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
882882
* Before entering the main loop, establish the invariant that
883883
* next_unskippable_block is the next block number >= blkno that we can't
884884
* skip based on the visibility map, either all-visible for a regular scan
885-
* or all-frozen for an aggressive scan. We set it to nblocks if there's
886-
* no such block. We also set up the skipping_blocks flag correctly at
887-
* this stage.
885+
* or all-frozen for an aggressive scan. We set it to rel_pages when
886+
* there's no such block. We also set up the skipping_blocks flag
887+
* correctly at this stage.
888888
*
889889
* Note: The value returned by visibilitymap_get_status could be slightly
890890
* out-of-date, since we make this test before reading the corresponding
@@ -902,7 +902,7 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
902902
next_unskippable_block = 0;
903903
if (vacrel->skipwithvm)
904904
{
905-
while (next_unskippable_block < nblocks)
905+
while (next_unskippable_block < rel_pages)
906906
{
907907
uint8 vmstatus;
908908

@@ -929,7 +929,7 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
929929
else
930930
skipping_blocks = false;
931931

932-
for (blkno = 0; blkno < nblocks; blkno++)
932+
for (blkno = 0; blkno < rel_pages; blkno++)
933933
{
934934
Buffer buf;
935935
Page page;
@@ -947,7 +947,7 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
947947
next_unskippable_block++;
948948
if (vacrel->skipwithvm)
949949
{
950-
while (next_unskippable_block < nblocks)
950+
while (next_unskippable_block < rel_pages)
951951
{
952952
uint8 vmskipflags;
953953

@@ -992,15 +992,15 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
992992
/*
993993
* The current page can be skipped if we've seen a long enough run
994994
* of skippable blocks to justify skipping it -- provided it's not
995-
* the last page in the relation (according to rel_pages/nblocks).
995+
* the last page in the relation (according to rel_pages).
996996
*
997997
* We always scan the table's last page to determine whether it
998998
* has tuples or not, even if it would otherwise be skipped. This
999999
* avoids having lazy_truncate_heap() take access-exclusive lock
10001000
* on the table to attempt a truncation that just fails
10011001
* immediately because there are tuples on the last page.
10021002
*/
1003-
if (skipping_blocks && blkno < nblocks - 1)
1003+
if (skipping_blocks && blkno < rel_pages - 1)
10041004
{
10051005
/*
10061006
* Tricky, tricky. If this is in aggressive vacuum, the page
@@ -1367,7 +1367,7 @@ lazy_scan_heap(LVRelState *vacrel, int nworkers)
13671367
vacrel->blkno = InvalidBlockNumber;
13681368

13691369
/* now we can compute the new value for pg_class.reltuples */
1370-
vacrel->new_live_tuples = vac_estimate_reltuples(vacrel->rel, nblocks,
1370+
vacrel->new_live_tuples = vac_estimate_reltuples(vacrel->rel, rel_pages,
13711371
vacrel->scanned_pages,
13721372
vacrel->live_tuples);
13731373

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy