@@ -2319,6 +2319,17 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23192319{
23202320 bool allindexes = true;
23212321 double old_live_tuples = vacrel -> rel -> rd_rel -> reltuples ;
2322+ const int progress_start_index [] = {
2323+ PROGRESS_VACUUM_PHASE ,
2324+ PROGRESS_VACUUM_INDEXES_TOTAL
2325+ };
2326+ const int progress_end_index [] = {
2327+ PROGRESS_VACUUM_INDEXES_TOTAL ,
2328+ PROGRESS_VACUUM_INDEXES_PROCESSED ,
2329+ PROGRESS_VACUUM_NUM_INDEX_VACUUMS
2330+ };
2331+ int64 progress_start_val [2 ];
2332+ int64 progress_end_val [3 ];
23222333
23232334 Assert (vacrel -> nindexes > 0 );
23242335 Assert (vacrel -> do_index_vacuuming );
@@ -2331,9 +2342,13 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23312342 return false;
23322343 }
23332344
2334- /* Report that we are now vacuuming indexes */
2335- pgstat_progress_update_param (PROGRESS_VACUUM_PHASE ,
2336- PROGRESS_VACUUM_PHASE_VACUUM_INDEX );
2345+ /*
2346+ * Report that we are now vacuuming indexes and the number of indexes to
2347+ * vacuum.
2348+ */
2349+ progress_start_val [0 ] = PROGRESS_VACUUM_PHASE_VACUUM_INDEX ;
2350+ progress_start_val [1 ] = vacrel -> nindexes ;
2351+ pgstat_progress_update_multi_param (2 , progress_start_index , progress_start_val );
23372352
23382353 if (!ParallelVacuumIsActive (vacrel ))
23392354 {
@@ -2346,6 +2361,10 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23462361 old_live_tuples ,
23472362 vacrel );
23482363
2364+ /* Report the number of indexes vacuumed */
2365+ pgstat_progress_update_param (PROGRESS_VACUUM_INDEXES_PROCESSED ,
2366+ idx + 1 );
2367+
23492368 if (lazy_check_wraparound_failsafe (vacrel ))
23502369 {
23512370 /* Wraparound emergency -- end current index scan */
@@ -2380,14 +2399,17 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23802399 Assert (allindexes || VacuumFailsafeActive );
23812400
23822401 /*
2383- * Increase and report the number of index scans.
2402+ * Increase and report the number of index scans. Also, we reset
2403+ * PROGRESS_VACUUM_INDEXES_TOTAL and PROGRESS_VACUUM_INDEXES_PROCESSED.
23842404 *
23852405 * We deliberately include the case where we started a round of bulk
23862406 * deletes that we weren't able to finish due to the failsafe triggering.
23872407 */
23882408 vacrel -> num_index_scans ++ ;
2389- pgstat_progress_update_param (PROGRESS_VACUUM_NUM_INDEX_VACUUMS ,
2390- vacrel -> num_index_scans );
2409+ progress_end_val [0 ] = 0 ;
2410+ progress_end_val [1 ] = 0 ;
2411+ progress_end_val [2 ] = vacrel -> num_index_scans ;
2412+ pgstat_progress_update_multi_param (3 , progress_end_index , progress_end_val );
23912413
23922414 return allindexes ;
23932415}
@@ -2624,6 +2646,12 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
26242646
26252647 if (unlikely (vacuum_xid_failsafe_check (& vacrel -> cutoffs )))
26262648 {
2649+ const int progress_index [] = {
2650+ PROGRESS_VACUUM_INDEXES_TOTAL ,
2651+ PROGRESS_VACUUM_INDEXES_PROCESSED
2652+ };
2653+ int64 progress_val [2 ] = {0 , 0 };
2654+
26272655 VacuumFailsafeActive = true;
26282656
26292657 /*
@@ -2638,6 +2666,9 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
26382666 vacrel -> do_index_cleanup = false;
26392667 vacrel -> do_rel_truncate = false;
26402668
2669+ /* Reset the progress counters */
2670+ pgstat_progress_update_multi_param (2 , progress_index , progress_val );
2671+
26412672 ereport (WARNING ,
26422673 (errmsg ("bypassing nonessential maintenance of table \"%s.%s.%s\" as a failsafe after %d index scans" ,
26432674 vacrel -> dbname , vacrel -> relnamespace , vacrel -> relname ,
@@ -2664,13 +2695,27 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
26642695{
26652696 double reltuples = vacrel -> new_rel_tuples ;
26662697 bool estimated_count = vacrel -> scanned_pages < vacrel -> rel_pages ;
2698+ const int progress_start_index [] = {
2699+ PROGRESS_VACUUM_PHASE ,
2700+ PROGRESS_VACUUM_INDEXES_TOTAL
2701+ };
2702+ const int progress_end_index [] = {
2703+ PROGRESS_VACUUM_INDEXES_TOTAL ,
2704+ PROGRESS_VACUUM_INDEXES_PROCESSED
2705+ };
2706+ int64 progress_start_val [2 ];
2707+ int64 progress_end_val [2 ] = {0 , 0 };
26672708
26682709 Assert (vacrel -> do_index_cleanup );
26692710 Assert (vacrel -> nindexes > 0 );
26702711
2671- /* Report that we are now cleaning up indexes */
2672- pgstat_progress_update_param (PROGRESS_VACUUM_PHASE ,
2673- PROGRESS_VACUUM_PHASE_INDEX_CLEANUP );
2712+ /*
2713+ * Report that we are now cleaning up indexes and the number of indexes to
2714+ * cleanup.
2715+ */
2716+ progress_start_val [0 ] = PROGRESS_VACUUM_PHASE_INDEX_CLEANUP ;
2717+ progress_start_val [1 ] = vacrel -> nindexes ;
2718+ pgstat_progress_update_multi_param (2 , progress_start_index , progress_start_val );
26742719
26752720 if (!ParallelVacuumIsActive (vacrel ))
26762721 {
@@ -2682,6 +2727,10 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
26822727 vacrel -> indstats [idx ] =
26832728 lazy_cleanup_one_index (indrel , istat , reltuples ,
26842729 estimated_count , vacrel );
2730+
2731+ /* Report the number of indexes cleaned up */
2732+ pgstat_progress_update_param (PROGRESS_VACUUM_INDEXES_PROCESSED ,
2733+ idx + 1 );
26852734 }
26862735 }
26872736 else
@@ -2691,6 +2740,9 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
26912740 vacrel -> num_index_scans ,
26922741 estimated_count );
26932742 }
2743+
2744+ /* Reset the progress counters */
2745+ pgstat_progress_update_multi_param (2 , progress_end_index , progress_end_val );
26942746}
26952747
26962748/*
0 commit comments