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

Commit a3c66de

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 4d346de commit a3c66de

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
@@ -1662,6 +1662,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
16621662
/* report that everything is scanned and vacuumed */
16631663
pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno);
16641664

1665+
/* Clear the block number information */
1666+
vacrelstats->blkno = InvalidBlockNumber;
1667+
16651668
pfree(frozen);
16661669

16671670
/* save stats for use later */
@@ -1879,6 +1882,9 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
18791882
npages++;
18801883
}
18811884

1885+
/* Clear the block number information */
1886+
vacrelstats->blkno = InvalidBlockNumber;
1887+
18821888
if (BufferIsValid(vmbuffer))
18831889
{
18841890
ReleaseBuffer(vmbuffer);
@@ -2496,30 +2502,30 @@ lazy_cleanup_index(Relation indrel,
24962502

24972503
*stats = index_vacuum_cleanup(&ivinfo, *stats);
24982504

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

25252531
/*
@@ -3582,12 +3588,18 @@ vacuum_error_callback(void *arg)
35823588
if (BlockNumberIsValid(errinfo->blkno))
35833589
errcontext("while scanning block %u of relation \"%s.%s\"",
35843590
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
3591+
else
3592+
errcontext("while scanning relation \"%s.%s\"",
3593+
errinfo->relnamespace, errinfo->relname);
35853594
break;
35863595

35873596
case VACUUM_ERRCB_PHASE_VACUUM_HEAP:
35883597
if (BlockNumberIsValid(errinfo->blkno))
35893598
errcontext("while vacuuming block %u of relation \"%s.%s\"",
35903599
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
3600+
else
3601+
errcontext("while vacuuming relation \"%s.%s\"",
3602+
errinfo->relnamespace, errinfo->relname);
35913603
break;
35923604

35933605
case VACUUM_ERRCB_PHASE_VACUUM_INDEX:

0 commit comments

Comments
 (0)