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

Commit6212276

Browse files
committed
Fix progress reporting of CLUSTER / VACUUM FULL
The progress state was being clobbered once the first index completedbeing rebuilt, causing the final phases of the operation not showanything in the progress view. This was inadvertently broken in03f9e5c, which added progress tracking for REINDEX.(The reason this bugfix is this small is that I had already noticed thisproblem when writing monitoring for CREATE INDEX, and had already workedaround it, as can be seen in discussion starting athttps://postgr.es/m/20190329150218.GA25010@alvherre.pgsql Fixing theproblem is just a matter of fixing one place touched by the REINDEXmonitoring.)Reported by: Álvaro HerreraAuthor: Álvaro HerreraDiscussion:https://postgr.es/m/20190801184333.GA21369@alvherre.pgsql
1 parenteb57bd9 commit6212276

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

‎src/backend/catalog/index.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,6 +3306,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
33063306
IndexInfo*indexInfo;
33073307
volatileboolskipped_constraint= false;
33083308
PGRUsageru0;
3309+
boolprogress= (options&REINDEXOPT_REPORT_PROGRESS)!=0;
33093310

33103311
pg_rusage_init(&ru0);
33113312

@@ -3316,21 +3317,25 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
33163317
heapId=IndexGetRelation(indexId, false);
33173318
heapRelation=table_open(heapId,ShareLock);
33183319

3319-
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
3320-
heapId);
3321-
pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
3322-
PROGRESS_CREATEIDX_COMMAND_REINDEX);
3323-
pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
3324-
indexId);
3320+
if (progress)
3321+
{
3322+
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
3323+
heapId);
3324+
pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
3325+
PROGRESS_CREATEIDX_COMMAND_REINDEX);
3326+
pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
3327+
indexId);
3328+
}
33253329

33263330
/*
33273331
* Open the target index relation and get an exclusive lock on it, to
33283332
* ensure that no one else is touching this particular index.
33293333
*/
33303334
iRel=index_open(indexId,AccessExclusiveLock);
33313335

3332-
pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID,
3333-
iRel->rd_rel->relam);
3336+
if (progress)
3337+
pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID,
3338+
iRel->rd_rel->relam);
33343339

33353340
/*
33363341
* The case of reindexing partitioned tables and indexes is handled
@@ -3483,7 +3488,8 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
34833488
errdetail_internal("%s",
34843489
pg_rusage_show(&ru0))));
34853490

3486-
pgstat_progress_end_command();
3491+
if (progress)
3492+
pgstat_progress_end_command();
34873493

34883494
/* Close rels, but keep locks */
34893495
index_close(iRel,NoLock);

‎src/backend/commands/indexcmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ ReindexTable(RangeVar *relation, int options, bool concurrent)
24532453
result=reindex_relation(heapOid,
24542454
REINDEX_REL_PROCESS_TOAST |
24552455
REINDEX_REL_CHECK_CONSTRAINTS,
2456-
options);
2456+
options |REINDEXOPT_REPORT_PROGRESS);
24572457
if (!result)
24582458
ereport(NOTICE,
24592459
(errmsg("table \"%s\" has no indexes to reindex",
@@ -2657,7 +2657,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
26572657
result=reindex_relation(relid,
26582658
REINDEX_REL_PROCESS_TOAST |
26592659
REINDEX_REL_CHECK_CONSTRAINTS,
2660-
options);
2660+
options |REINDEXOPT_REPORT_PROGRESS);
26612661

26622662
if (result&& (options&REINDEXOPT_VERBOSE))
26632663
ereport(INFO,

‎src/include/nodes/parsenodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,7 @@ typedef struct ConstraintsSetStmt
33133313

33143314
/* Reindex options */
33153315
#defineREINDEXOPT_VERBOSE 1 << 0/* print progress info */
3316+
#defineREINDEXOPT_REPORT_PROGRESS 1 << 1/* report pgstat progress */
33163317

33173318
typedefenumReindexObjectType
33183319
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp