git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b2d0c7c)
Fix autovacuum log output heap truncation issue.
2021年5月13日 23:07:17 +0000 (16:07 -0700)
2021年5月13日 23:07:17 +0000 (16:07 -0700)
The percentage of blocks from the table value reported by autovacuum log
output (following commit 5100010ee4d) should never exceed 100% because
it describes the state of the table back when lazy_vacuum() was called.
The value could nevertheless exceed 100% in the event of heap relation
truncation. We failed to compensate for how truncation affects
rel_pages.

Fix the faulty accounting by using the original rel_pages value instead
of the current/final rel_pages value.

Reported-By: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20210423204306.5osfpkt2ggaedyvy@alap3.anarazel.de


diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 17519a970fe95b5c46f85be114c7321d3e0bd859..9f1f8e340d9a391ff1e5755c5e27ed7975abb5f6 100644 (file)
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -777,6 +777,8 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
(long long) VacuumPageDirty);
if (vacrel->rel_pages > 0)
{
+ BlockNumber orig_rel_pages;
+
if (vacrel->do_index_vacuuming)
{
msgfmt = _(" %u pages from table (%.2f%% of total) had %lld dead item identifiers removed\n");
@@ -795,9 +797,10 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
else
appendStringInfo(&buf, _("index scan bypassed by failsafe:"));
}
+ orig_rel_pages = vacrel->rel_pages + vacrel->pages_removed;
appendStringInfo(&buf, msgfmt,
vacrel->lpdead_item_pages,
- 100.0 * vacrel->lpdead_item_pages / vacrel->rel_pages,
+ 100.0 * vacrel->lpdead_item_pages / orig_rel_pages,
(long long) vacrel->lpdead_items);
}
for (int i = 0; i < vacrel->nindexes; i++)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /