Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b4ef5ac

Browse files
author
Amit Kapila
committed
Improve the vacuum error context phase information.
We were displaying the wrong phase information for 'info' message in the index clean up phase because we were switching to the previous phase a bit early. We were also not displaying context information for heap phase unless the block number is valid which is fine for error cases but for messages at 'info' or lower error level it appears to be inconsistent with index phase information. Reported-by: Sawada Masahiko Author: Sawada Masahiko Reviewed-by: Amit Kapila Backpatch-through: 13, where it was introduced Discussion: https://postgr.es/m/CA+fd4k4HcbhPnCs7paRTw1K-AHin8y4xKomB9Ru0ATw0UeTy2w@mail.gmail.com
1 parent de627ad commit b4ef5ac

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

src/backend/access/heap/vacuumlazy.c

+32-20
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
16561656
/* report that everything is scanned and vacuumed */
16571657
pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno);
16581658

1659+
/* Clear the block number information */
1660+
vacrelstats->blkno = InvalidBlockNumber;
1661+
16591662
pfree(frozen);
16601663

16611664
/* save stats for use later */
@@ -1873,6 +1876,9 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
18731876
npages++;
18741877
}
18751878

1879+
/* Clear the block number information */
1880+
vacrelstats->blkno = InvalidBlockNumber;
1881+
18761882
if (BufferIsValid(vmbuffer))
18771883
{
18781884
ReleaseBuffer(vmbuffer);
@@ -2490,30 +2496,30 @@ lazy_cleanup_index(Relation indrel,
24902496

24912497
*stats = index_vacuum_cleanup(&ivinfo, *stats);
24922498

2499+
if (*stats)
2500+
{
2501+
if (IsParallelWorker())
2502+
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages as reported by parallel vacuum worker");
2503+
else
2504+
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages");
2505+
2506+
ereport(elevel,
2507+
(errmsg(msg,
2508+
RelationGetRelationName(indrel),
2509+
(*stats)->num_index_tuples,
2510+
(*stats)->num_pages),
2511+
errdetail("%.0f index row versions were removed.\n"
2512+
"%u index pages have been deleted, %u are currently reusable.\n"
2513+
"%s.",
2514+
(*stats)->tuples_removed,
2515+
(*stats)->pages_deleted, (*stats)->pages_free,
2516+
pg_rusage_show(&ru0))));
2517+
}
2518+
24932519
/* Revert back to the old phase information for error traceback */
24942520
restore_vacuum_error_info(vacrelstats, &saved_err_info);
24952521
pfree(vacrelstats->indname);
24962522
vacrelstats->indname = NULL;
2497-
2498-
if (!(*stats))
2499-
return;
2500-
2501-
if (IsParallelWorker())
2502-
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages as reported by parallel vacuum worker");
2503-
else
2504-
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages");
2505-
2506-
ereport(elevel,
2507-
(errmsg(msg,
2508-
RelationGetRelationName(indrel),
2509-
(*stats)->num_index_tuples,
2510-
(*stats)->num_pages),
2511-
errdetail("%.0f index row versions were removed.\n"
2512-
"%u index pages have been deleted, %u are currently reusable.\n"
2513-
"%s.",
2514-
(*stats)->tuples_removed,
2515-
(*stats)->pages_deleted, (*stats)->pages_free,
2516-
pg_rusage_show(&ru0))));
25172523
}
25182524

25192525
/*
@@ -3576,12 +3582,18 @@ vacuum_error_callback(void *arg)
35763582
if (BlockNumberIsValid(errinfo->blkno))
35773583
errcontext("while scanning block %u of relation \"%s.%s\"",
35783584
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
3585+
else
3586+
errcontext("while scanning relation \"%s.%s\"",
3587+
errinfo->relnamespace, errinfo->relname);
35793588
break;
35803589

35813590
case VACUUM_ERRCB_PHASE_VACUUM_HEAP:
35823591
if (BlockNumberIsValid(errinfo->blkno))
35833592
errcontext("while vacuuming block %u of relation \"%s.%s\"",
35843593
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
3594+
else
3595+
errcontext("while vacuuming relation \"%s.%s\"",
3596+
errinfo->relnamespace, errinfo->relname);
35853597
break;
35863598

35873599
case VACUUM_ERRCB_PHASE_VACUUM_INDEX:

0 commit comments

Comments
 (0)