Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46ebdfe

Browse files
Report index vacuum progress.
This commit adds two columns: indexes_total and indexes_processed, topg_stat_progress_vacuum system view to show the index vacuumprogress. These numbers are reported in the "vacuuming indexes" and"cleaning up indexes" phases.This uses the new parallel message type for progress reporting addedby be06506e7.Bump catversion because this changes the definition ofpg_stat_progress_vacuum.Author: Sami ImseihReviewed by: Masahiko Sawada, Michael Paquier, Nathan Bossart, Andres FreundDiscussion:https://www.postgresql.org/message-id/flat/5478DFCD-2333-401A-B2F0-0D186AB09228@amazon.com
1 parentf188972 commit46ebdfe

File tree

7 files changed

+100
-13
lines changed

7 files changed

+100
-13
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6110,6 +6110,29 @@ FROM pg_stat_get_backend_idset() AS backendid;
61106110
Number of dead tuples collected since the last index vacuum cycle.
61116111
</para></entry>
61126112
</row>
6113+
6114+
<row>
6115+
<entry role="catalog_table_entry"><para role="column_definition">
6116+
<structfield>indexes_total</structfield> <type>bigint</type>
6117+
</para>
6118+
<para>
6119+
Total number of indexes that will be vacuumed or cleaned up. This
6120+
number is reported at the beginning of the
6121+
<literal>vacuuming indexes</literal> phase or the
6122+
<literal>cleaning up indexes</literal> phase.
6123+
</para></entry>
6124+
</row>
6125+
6126+
<row>
6127+
<entry role="catalog_table_entry"><para role="column_definition">
6128+
<structfield>indexes_processed</structfield> <type>bigint</type>
6129+
</para>
6130+
<para>
6131+
Number of indexes processed. This counter only advances when the
6132+
phase is <literal>vacuuming indexes</literal> or
6133+
<literal>cleaning up indexes</literal>.
6134+
</para></entry>
6135+
</row>
61136136
</tbody>
61146137
</tgroup>
61156138
</table>

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,17 @@ lazy_vacuum_all_indexes(LVRelState *vacrel)
23192319
{
23202320
boolallindexes= true;
23212321
doubleold_live_tuples=vacrel->rel->rd_rel->reltuples;
2322+
constintprogress_start_index[]= {
2323+
PROGRESS_VACUUM_PHASE,
2324+
PROGRESS_VACUUM_INDEXES_TOTAL
2325+
};
2326+
constintprogress_end_index[]= {
2327+
PROGRESS_VACUUM_INDEXES_TOTAL,
2328+
PROGRESS_VACUUM_INDEXES_PROCESSED,
2329+
PROGRESS_VACUUM_NUM_INDEX_VACUUMS
2330+
};
2331+
int64progress_start_val[2];
2332+
int64progress_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
returnallindexes;
23932415
}
@@ -2624,6 +2646,12 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
26242646

26252647
if (unlikely(vacuum_xid_failsafe_check(&vacrel->cutoffs)))
26262648
{
2649+
constintprogress_index[]= {
2650+
PROGRESS_VACUUM_INDEXES_TOTAL,
2651+
PROGRESS_VACUUM_INDEXES_PROCESSED
2652+
};
2653+
int64progress_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
doublereltuples=vacrel->new_rel_tuples;
26662697
boolestimated_count=vacrel->scanned_pages<vacrel->rel_pages;
2698+
constintprogress_start_index[]= {
2699+
PROGRESS_VACUUM_PHASE,
2700+
PROGRESS_VACUUM_INDEXES_TOTAL
2701+
};
2702+
constintprogress_end_index[]= {
2703+
PROGRESS_VACUUM_INDEXES_TOTAL,
2704+
PROGRESS_VACUUM_INDEXES_PROCESSED
2705+
};
2706+
int64progress_start_val[2];
2707+
int64progress_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
/*

‎src/backend/catalog/system_views.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,8 @@ CREATE VIEW pg_stat_progress_vacuum AS
11921192
ENDAS phase,
11931193
S.param2AS heap_blks_total,S.param3AS heap_blks_scanned,
11941194
S.param4AS heap_blks_vacuumed,S.param5AS index_vacuum_count,
1195-
S.param6AS max_dead_tuples,S.param7AS num_dead_tuples
1195+
S.param6AS max_dead_tuples,S.param7AS num_dead_tuples,
1196+
S.param8AS indexes_total,S.param9AS indexes_processed
11961197
FROM pg_stat_get_progress_info('VACUUM')AS S
11971198
LEFT JOIN pg_database DONS.datid=D.oid;
11981199

‎src/backend/commands/vacuumparallel.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include"access/table.h"
3131
#include"access/xact.h"
3232
#include"catalog/index.h"
33+
#include"commands/progress.h"
3334
#include"commands/vacuum.h"
3435
#include"optimizer/paths.h"
3536
#include"pgstat.h"
@@ -631,7 +632,7 @@ parallel_vacuum_process_all_indexes(ParallelVacuumState *pvs, int num_index_scan
631632
vacuum));
632633
}
633634

634-
/* Reset the parallel index processingcounter */
635+
/* Reset the parallel index processingand progress counters */
635636
pg_atomic_write_u32(&(pvs->shared->idx),0);
636637

637638
/* Setup the shared cost-based vacuum delay and launch workers */
@@ -902,6 +903,12 @@ parallel_vacuum_process_one_index(ParallelVacuumState *pvs, Relation indrel,
902903
pvs->status=PARALLEL_INDVAC_STATUS_COMPLETED;
903904
pfree(pvs->indname);
904905
pvs->indname=NULL;
906+
907+
/*
908+
* Call the parallel variant of pgstat_progress_incr_param so workers can
909+
* report progress of index vacuum to the leader.
910+
*/
911+
pgstat_progress_parallel_incr_param(PROGRESS_VACUUM_INDEXES_PROCESSED,1);
905912
}
906913

907914
/*

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/*yyyymmddN */
60-
#defineCATALOG_VERSION_NO202307072
60+
#defineCATALOG_VERSION_NO202307111
6161

6262
#endif

‎src/include/commands/progress.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#definePROGRESS_VACUUM_NUM_INDEX_VACUUMS4
2626
#definePROGRESS_VACUUM_MAX_DEAD_TUPLES5
2727
#definePROGRESS_VACUUM_NUM_DEAD_TUPLES6
28+
#definePROGRESS_VACUUM_INDEXES_TOTAL7
29+
#definePROGRESS_VACUUM_INDEXES_PROCESSED8
2830

2931
/* Phases of vacuum (as advertised via PROGRESS_VACUUM_PHASE) */
3032
#definePROGRESS_VACUUM_PHASE_SCAN_HEAP1

‎src/test/regress/expected/rules.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,9 @@ pg_stat_progress_vacuum| SELECT s.pid,
20442044
s.param4 AS heap_blks_vacuumed,
20452045
s.param5 AS index_vacuum_count,
20462046
s.param6 AS max_dead_tuples,
2047-
s.param7 AS num_dead_tuples
2047+
s.param7 AS num_dead_tuples,
2048+
s.param8 AS indexes_total,
2049+
s.param9 AS indexes_processed
20482050
FROM (pg_stat_get_progress_info('VACUUM'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
20492051
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
20502052
pg_stat_recovery_prefetch| SELECT stats_reset,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp