@@ -2319,6 +2319,17 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
2319
2319
{
2320
2320
bool allindexes = true;
2321
2321
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 ];
2322
2333
2323
2334
Assert (vacrel -> nindexes > 0 );
2324
2335
Assert (vacrel -> do_index_vacuuming );
@@ -2331,9 +2342,13 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
2331
2342
return false;
2332
2343
}
2333
2344
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 );
2337
2352
2338
2353
if (!ParallelVacuumIsActive (vacrel ))
2339
2354
{
@@ -2346,6 +2361,10 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
2346
2361
old_live_tuples ,
2347
2362
vacrel );
2348
2363
2364
+ /* Report the number of indexes vacuumed */
2365
+ pgstat_progress_update_param (PROGRESS_VACUUM_INDEXES_PROCESSED ,
2366
+ idx + 1 );
2367
+
2349
2368
if (lazy_check_wraparound_failsafe (vacrel ))
2350
2369
{
2351
2370
/* Wraparound emergency -- end current index scan */
@@ -2380,14 +2399,17 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
2380
2399
Assert (allindexes || VacuumFailsafeActive );
2381
2400
2382
2401
/*
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.
2384
2404
*
2385
2405
* We deliberately include the case where we started a round of bulk
2386
2406
* deletes that we weren't able to finish due to the failsafe triggering.
2387
2407
*/
2388
2408
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 );
2391
2413
2392
2414
return allindexes ;
2393
2415
}
@@ -2624,6 +2646,12 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
2624
2646
2625
2647
if (unlikely (vacuum_xid_failsafe_check (& vacrel -> cutoffs )))
2626
2648
{
2649
+ const int progress_index [] = {
2650
+ PROGRESS_VACUUM_INDEXES_TOTAL ,
2651
+ PROGRESS_VACUUM_INDEXES_PROCESSED
2652
+ };
2653
+ int64 progress_val [2 ] = {0 , 0 };
2654
+
2627
2655
VacuumFailsafeActive = true;
2628
2656
2629
2657
/*
@@ -2638,6 +2666,9 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
2638
2666
vacrel -> do_index_cleanup = false;
2639
2667
vacrel -> do_rel_truncate = false;
2640
2668
2669
+ /* Reset the progress counters */
2670
+ pgstat_progress_update_multi_param (2 , progress_index , progress_val );
2671
+
2641
2672
ereport (WARNING ,
2642
2673
(errmsg ("bypassing nonessential maintenance of table \"%s.%s.%s\" as a failsafe after %d index scans" ,
2643
2674
vacrel -> dbname , vacrel -> relnamespace , vacrel -> relname ,
@@ -2664,13 +2695,27 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
2664
2695
{
2665
2696
double reltuples = vacrel -> new_rel_tuples ;
2666
2697
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 };
2667
2708
2668
2709
Assert (vacrel -> do_index_cleanup );
2669
2710
Assert (vacrel -> nindexes > 0 );
2670
2711
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 );
2674
2719
2675
2720
if (!ParallelVacuumIsActive (vacrel ))
2676
2721
{
@@ -2682,6 +2727,10 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
2682
2727
vacrel -> indstats [idx ] =
2683
2728
lazy_cleanup_one_index (indrel , istat , reltuples ,
2684
2729
estimated_count , vacrel );
2730
+
2731
+ /* Report the number of indexes cleaned up */
2732
+ pgstat_progress_update_param (PROGRESS_VACUUM_INDEXES_PROCESSED ,
2733
+ idx + 1 );
2685
2734
}
2686
2735
}
2687
2736
else
@@ -2691,6 +2740,9 @@ lazy_cleanup_all_indexes(LVRelState *vacrel)
2691
2740
vacrel -> num_index_scans ,
2692
2741
estimated_count );
2693
2742
}
2743
+
2744
+ /* Reset the progress counters */
2745
+ pgstat_progress_update_multi_param (2 , progress_end_index , progress_end_val );
2694
2746
}
2695
2747
2696
2748
/*
0 commit comments