Skip to content

Commit 17eaae9

Browse files
committed
Fix logging of pages skipped due to pins during vacuum.
The new logging introduced in 35192f0 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
1 parent 2048e5b commit 17eaae9

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ typedef struct LVRelStats
105105
BlockNumber old_rel_pages; /* previous value of pg_class.relpages */
106106
BlockNumber rel_pages; /* total number of pages */
107107
BlockNumber scanned_pages; /* number of pages we examined */
108-
BlockNumber pinned_pages; /* # of pages we could not initially lock */
108+
BlockNumber pinskipped_pages; /* # of pages we skipped due to a pin */
109109
double scanned_tuples; /* counts only tuples on scanned pages */
110110
double old_rel_tuples; /* previous value of pg_class.reltuples */
111111
double new_rel_tuples; /* new estimated total # of tuples */
@@ -356,19 +356,10 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
356356
get_namespace_name(RelationGetNamespace(onerel)),
357357
RelationGetRelationName(onerel),
358358
vacrelstats->num_index_scans);
359-
appendStringInfo(&buf, _("pages: %u removed, %u remain\n"),
359+
appendStringInfo(&buf, _("pages: %u removed, %u remain, %u skipped due to pins\n"),
360360
vacrelstats->pages_removed,
361-
vacrelstats->rel_pages);
362-
if (vacrelstats->pinned_pages > 0)
363-
{
364-
if (scan_all)
365-
appendStringInfo(&buf, _("waited for %u buffer pins\n"),
366-
vacrelstats->pinned_pages);
367-
else
368-
appendStringInfo(&buf,
369-
_("skipped %u pages due to buffer pins\n"),
370-
vacrelstats->pinned_pages);
371-
}
361+
vacrelstats->rel_pages,
362+
vacrelstats->pinskipped_pages);
372363
appendStringInfo(&buf,
373364
_("tuples: %.0f removed, %.0f remain, %.0f are dead but not yet removable\n"),
374365
vacrelstats->tuples_deleted,
@@ -634,8 +625,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
634625
/* We need buffer cleanup lock so that we can prune HOT chains. */
635626
if (!ConditionalLockBufferForCleanup(buf))
636627
{
637-
vacrelstats->pinned_pages++;
638-
639628
/*
640629
* If we're not scanning the whole relation to guard against XID
641630
* wraparound, it's OK to skip vacuuming a page. The next vacuum
@@ -644,6 +633,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
644633
if (!scan_all)
645634
{
646635
ReleaseBuffer(buf);
636+
vacrelstats->pinskipped_pages++;
647637
continue;
648638
}
649639

@@ -663,6 +653,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
663653
{
664654
UnlockReleaseBuffer(buf);
665655
vacrelstats->scanned_pages++;
656+
vacrelstats->pinskipped_pages++;
666657
continue;
667658
}
668659
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
@@ -1129,15 +1120,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
11291120
nkeep);
11301121
appendStringInfo(&buf, _("There were %.0f unused item pointers.\n"),
11311122
nunused);
1132-
if (vacrelstats->pinned_pages > 0)
1133-
{
1134-
if (scan_all)
1135-
appendStringInfo(&buf, _("Waited for %u buffer pins.\n"),
1136-
vacrelstats->pinned_pages);
1137-
else
1138-
appendStringInfo(&buf, _("Skipped %u pages due to buffer pins.\n"),
1139-
vacrelstats->pinned_pages);
1140-
}
1123+
appendStringInfo(&buf, _("Skipped %u pages due to buffer pins.\n"),
1124+
vacrelstats->pinskipped_pages);
11411125
appendStringInfo(&buf, _("%u pages are entirely empty.\n"),
11421126
empty_pages);
11431127
appendStringInfo(&buf, _("%s."),

0 commit comments

Comments
 (0)