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

Commitf188972

Browse files
Add new parallel message type to progress reporting.
This commit adds a new type of parallel message 'P' to allow aparallel worker to poke at a leader to update the progress.Currently it supports only incremental progress reporting but it'spossible to allow for supporting of other backend progress APIs in thefuture.There are no users of this new message type as of this commit. Thatwill follow in future commits.Idea from Andres Freund.Author: Sami ImseihReviewed by: Michael Paquier, Masahiko SawadaDiscussion:https://www.postgresql.org/message-id/flat/5478DFCD-2333-401A-B2F0-0D186AB09228@amazon.com
1 parent26dd028 commitf188972

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include"catalog/pg_enum.h"
2525
#include"catalog/storage.h"
2626
#include"commands/async.h"
27+
#include"commands/progress.h"
2728
#include"commands/vacuum.h"
2829
#include"executor/execParallel.h"
2930
#include"libpq/libpq.h"
@@ -1199,6 +1200,23 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
11991200
break;
12001201
}
12011202

1203+
case'P':/* Parallel progress reporting */
1204+
{
1205+
/*
1206+
* Only incremental progress reporting is currently supported.
1207+
* However, it's possible to add more fields to the message to
1208+
* allow for handling of other backend progress APIs.
1209+
*/
1210+
intindex=pq_getmsgint(msg,4);
1211+
int64incr=pq_getmsgint64(msg);
1212+
1213+
pq_getmsgend(msg);
1214+
1215+
pgstat_progress_incr_param(index,incr);
1216+
1217+
break;
1218+
}
1219+
12021220
case'X':/* Terminate, indicating clean exit */
12031221
{
12041222
shm_mq_detach(pcxt->worker[i].error_mqh);

‎src/backend/utils/activity/backend_progress.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
#include"postgres.h"
1212

13+
#include"access/parallel.h"
14+
#include"libpq/pqformat.h"
1315
#include"port/atomics.h"/* for memory barriers */
1416
#include"utils/backend_progress.h"
1517
#include"utils/backend_status.h"
@@ -79,6 +81,36 @@ pgstat_progress_incr_param(int index, int64 incr)
7981
PGSTAT_END_WRITE_ACTIVITY(beentry);
8082
}
8183

84+
/*-----------
85+
* pgstat_progress_parallel_incr_param() -
86+
*
87+
* A variant of pgstat_progress_incr_param to allow a worker to poke at
88+
* a leader to do an incremental progress update.
89+
*-----------
90+
*/
91+
void
92+
pgstat_progress_parallel_incr_param(intindex,int64incr)
93+
{
94+
/*
95+
* Parallel workers notify a leader through a 'P' protocol message to
96+
* update progress, passing the progress index and incremented value.
97+
* Leaders can just call pgstat_progress_incr_param directly.
98+
*/
99+
if (IsParallelWorker())
100+
{
101+
staticStringInfoDataprogress_message;
102+
103+
initStringInfo(&progress_message);
104+
105+
pq_beginmessage(&progress_message,'P');
106+
pq_sendint32(&progress_message,index);
107+
pq_sendint64(&progress_message,incr);
108+
pq_endmessage(&progress_message);
109+
}
110+
else
111+
pgstat_progress_incr_param(index,incr);
112+
}
113+
82114
/*-----------
83115
* pgstat_progress_update_multi_param() -
84116
*

‎src/include/utils/backend_progress.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern void pgstat_progress_start_command(ProgressCommandType cmdtype,
3737
Oidrelid);
3838
externvoidpgstat_progress_update_param(intindex,int64val);
3939
externvoidpgstat_progress_incr_param(intindex,int64incr);
40+
externvoidpgstat_progress_parallel_incr_param(intindex,int64incr);
4041
externvoidpgstat_progress_update_multi_param(intnparam,constint*index,
4142
constint64*val);
4243
externvoidpgstat_progress_end_command(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp