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

Commit0f61727

Browse files
committed
Fixes for query_id feature
Ignore parallel workers in pg_stat_statements Oversight in4f0b096 which exposed queryid in parallel workers. Counters are aggregated by the main backend process so parallel workers would report duplicated activity, and could also report activity for the wrong entry as they are only aware of the top level queryid.Fix thinko in pg_stat_get_activity when retrieving the queryid.Remove unnecessary call to pgstat_report_queryid().Reported-by: Amit Kapila, Andres Freund, Thomas MunroDiscussion:https://postgr.es/m/20210408051735.lfbdzun5zdlax5gd@alap3.anarazel.de p634GTSOqnDW86Owrn6qDAVosC5dJjXjp7BMfc5Gz1Q@mail.gmail.comAuthor: Julien Rouhaud
1 parent5844c23 commit0f61727

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include<sys/stat.h>
4848
#include<unistd.h>
4949

50+
#include"access/parallel.h"
5051
#include"catalog/pg_authid.h"
5152
#include"common/hashfn.h"
5253
#include"executor/instrument.h"
@@ -278,8 +279,9 @@ static bool pgss_save;/* whether to save stats across shutdown */
278279

279280

280281
#definepgss_enabled(level) \
282+
(!IsParallelWorker() && \
281283
(pgss_track == PGSS_TRACK_ALL || \
282-
(pgss_track == PGSS_TRACK_TOP && (level) == 0))
284+
(pgss_track == PGSS_TRACK_TOP && (level) == 0)))
283285

284286
#definerecord_gc_qtexts() \
285287
do { \

‎src/backend/executor/execParallel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,6 @@ ParallelQueryMain(dsm_segment *seg, shm_toc *toc)
14261426

14271427
/* Report workers' query and queryId for monitoring purposes */
14281428
pgstat_report_activity(STATE_RUNNING,debug_query_string);
1429-
pgstat_report_queryid(queryDesc->plannedstmt->queryId, false);
14301429

14311430
/* Attach to the dynamic shared memory area. */
14321431
area_space=shm_toc_lookup(toc,PARALLEL_KEY_DSA, false);

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
917917
if (beentry->st_queryid==0)
918918
nulls[29]= true;
919919
else
920-
values[29]=DatumGetUInt64(beentry->st_queryid);
920+
values[29]=UInt64GetDatum(beentry->st_queryid);
921921
}
922922
else
923923
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp