postgres.git / summary / log / commit / refs

commit    17eaae9897781c6dcc622b9327899329e4d2a4df
Author:   Andres Freund <andres@anarazel.de>
Date:     Thu Jan 08 11:57:09 2015 +0000
First released in: 9.5.0

    Fix logging of pages skipped due to pins during vacuum.
    
    The new logging introduced in 35192f06 made the incorrect assumption
    that scan_all vacuums would always wait for buffer pins; but they only
    do so if the page actually needs to be frozen.
    
    Fix that inaccuracy by removing the difference in log output based on
    scan_all and just always remove the same message.  I chose to keep the
    split log message from the original commit for now, it seems likely
    that it'll be of use in the future.
    
    Also merge the line about buffer pins in autovacuum's log output into
    the existing "pages: ..." line. It seems odd to have a separate line
    about pins, without the "topic: " prefix others have.
    
    Also rename the new 'pinned_pages' variable to 'pinskipped_pages'
    because it actually tracks the number of pages that could *not* be
    pinned.
    
    Discussion: 20150104005324.GC9626@awork2.anarazel.de


src/backend/commands/vacuumlazy.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index e653bbdd48d..7d9e49eb330 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -105,7 +105,7 @@ typedef struct LVRelStats BlockNumber old_rel_pages; /* previous value of pg_class.relpages */ BlockNumber rel_pages; /* total number of pages */ BlockNumber scanned_pages; /* number of pages we examined */ - BlockNumber pinned_pages; /* # of pages we could not initially lock */ + BlockNumber pinskipped_pages; /* # of pages we skipped due to a pin */ double scanned_tuples; /* counts only tuples on scanned pages */ double old_rel_tuples; /* previous value of pg_class.reltuples */ double new_rel_tuples; /* new estimated total # of tuples */ @@ -356,19 +356,10 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt, get_namespace_name(RelationGetNamespace(onerel)), RelationGetRelationName(onerel), vacrelstats->num_index_scans); - appendStringInfo(&buf, _("pages: %u removed, %u remain\n"), + appendStringInfo(&buf, _("pages: %u removed, %u remain, %u skipped due to pins\n"), vacrelstats->pages_removed, - vacrelstats->rel_pages); - if (vacrelstats->pinned_pages > 0) - { - if (scan_all) - appendStringInfo(&buf, _("waited for %u buffer pins\n"), - vacrelstats->pinned_pages); - else - appendStringInfo(&buf, - _("skipped %u pages due to buffer pins\n"), - vacrelstats->pinned_pages); - } + vacrelstats->rel_pages, + vacrelstats->pinskipped_pages); appendStringInfo(&buf, _("tuples: %.0f removed, %.0f remain, %.0f are dead but not yet removable\n"), vacrelstats->tuples_deleted, @@ -634,8 +625,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, /* We need buffer cleanup lock so that we can prune HOT chains. */ if (!ConditionalLockBufferForCleanup(buf)) { - vacrelstats->pinned_pages++; - /* * If we're not scanning the whole relation to guard against XID * wraparound, it's OK to skip vacuuming a page. The next vacuum @@ -644,6 +633,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, if (!scan_all) { ReleaseBuffer(buf); + vacrelstats->pinskipped_pages++; continue; } @@ -663,6 +653,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, { UnlockReleaseBuffer(buf); vacrelstats->scanned_pages++; + vacrelstats->pinskipped_pages++; continue; } LockBuffer(buf, BUFFER_LOCK_UNLOCK); @@ -1129,15 +1120,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, nkeep); appendStringInfo(&buf, _("There were %.0f unused item pointers.\n"), nunused); - if (vacrelstats->pinned_pages > 0) - { - if (scan_all) - appendStringInfo(&buf, _("Waited for %u buffer pins.\n"), - vacrelstats->pinned_pages); - else - appendStringInfo(&buf, _("Skipped %u pages due to buffer pins.\n"), - vacrelstats->pinned_pages); - } + appendStringInfo(&buf, _("Skipped %u pages due to buffer pins.\n"), + vacrelstats->pinskipped_pages); appendStringInfo(&buf, _("%u pages are entirely empty.\n"), empty_pages); appendStringInfo(&buf, _("%s."), [parent: 2048e5b88198]