mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-07-31 09:43:28 +02:00
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
This commit is contained in:
parent
de627adaad
commit
b4ef5ac0b7
@ -1656,6 +1656,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
|
|||||||
/* report that everything is scanned and vacuumed */
|
/* report that everything is scanned and vacuumed */
|
||||||
pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno);
|
pgstat_progress_update_param(PROGRESS_VACUUM_HEAP_BLKS_SCANNED, blkno);
|
||||||
|
|
||||||
|
/* Clear the block number information */
|
||||||
|
vacrelstats->blkno = InvalidBlockNumber;
|
||||||
|
|
||||||
pfree(frozen);
|
pfree(frozen);
|
||||||
|
|
||||||
/* save stats for use later */
|
/* save stats for use later */
|
||||||
@ -1873,6 +1876,9 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
|
|||||||
npages++;
|
npages++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear the block number information */
|
||||||
|
vacrelstats->blkno = InvalidBlockNumber;
|
||||||
|
|
||||||
if (BufferIsValid(vmbuffer))
|
if (BufferIsValid(vmbuffer))
|
||||||
{
|
{
|
||||||
ReleaseBuffer(vmbuffer);
|
ReleaseBuffer(vmbuffer);
|
||||||
@ -2490,14 +2496,8 @@ lazy_cleanup_index(Relation indrel,
|
|||||||
|
|
||||||
*stats = index_vacuum_cleanup(&ivinfo, *stats);
|
*stats = index_vacuum_cleanup(&ivinfo, *stats);
|
||||||
|
|
||||||
/* Revert back to the old phase information for error traceback */
|
if (*stats)
|
||||||
restore_vacuum_error_info(vacrelstats, &saved_err_info);
|
{
|
||||||
pfree(vacrelstats->indname);
|
|
||||||
vacrelstats->indname = NULL;
|
|
||||||
|
|
||||||
if (!(*stats))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (IsParallelWorker())
|
if (IsParallelWorker())
|
||||||
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages as reported by parallel vacuum worker");
|
msg = gettext_noop("index \"%s\" now contains %.0f row versions in %u pages as reported by parallel vacuum worker");
|
||||||
else
|
else
|
||||||
@ -2514,6 +2514,12 @@ lazy_cleanup_index(Relation indrel,
|
|||||||
(*stats)->tuples_removed,
|
(*stats)->tuples_removed,
|
||||||
(*stats)->pages_deleted, (*stats)->pages_free,
|
(*stats)->pages_deleted, (*stats)->pages_free,
|
||||||
pg_rusage_show(&ru0))));
|
pg_rusage_show(&ru0))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Revert back to the old phase information for error traceback */
|
||||||
|
restore_vacuum_error_info(vacrelstats, &saved_err_info);
|
||||||
|
pfree(vacrelstats->indname);
|
||||||
|
vacrelstats->indname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3576,12 +3582,18 @@ vacuum_error_callback(void *arg)
|
|||||||
if (BlockNumberIsValid(errinfo->blkno))
|
if (BlockNumberIsValid(errinfo->blkno))
|
||||||
errcontext("while scanning block %u of relation \"%s.%s\"",
|
errcontext("while scanning block %u of relation \"%s.%s\"",
|
||||||
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
|
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
|
||||||
|
else
|
||||||
|
errcontext("while scanning relation \"%s.%s\"",
|
||||||
|
errinfo->relnamespace, errinfo->relname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VACUUM_ERRCB_PHASE_VACUUM_HEAP:
|
case VACUUM_ERRCB_PHASE_VACUUM_HEAP:
|
||||||
if (BlockNumberIsValid(errinfo->blkno))
|
if (BlockNumberIsValid(errinfo->blkno))
|
||||||
errcontext("while vacuuming block %u of relation \"%s.%s\"",
|
errcontext("while vacuuming block %u of relation \"%s.%s\"",
|
||||||
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
|
errinfo->blkno, errinfo->relnamespace, errinfo->relname);
|
||||||
|
else
|
||||||
|
errcontext("while vacuuming relation \"%s.%s\"",
|
||||||
|
errinfo->relnamespace, errinfo->relname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VACUUM_ERRCB_PHASE_VACUUM_INDEX:
|
case VACUUM_ERRCB_PHASE_VACUUM_INDEX:
|
||||||
|
Loading…
Reference in New Issue
Block a user