From 30948311d2cbba4154a88a731ef57b083688cbf1 Mon Sep 17 00:00:00 2001 From: Wang Hao Date: Wed, 3 Aug 2016 13:52:30 +0800 Subject: [PATCH] Fix gpperfmon bug that explain/analyze statement produce a wrong tsubmit in queries_now (#1017) --- src/backend/commands/explain.c | 12 ++++++++++++ src/backend/tcop/pquery.c | 22 ---------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 4fcd4ce942..d169967de6 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -20,6 +20,7 @@ #include "commands/explain.h" #include "commands/prepare.h" #include "commands/trigger.h" +#include "commands/queue.h" #include "executor/execUtils.h" #include "executor/instrument.h" #include "nodes/pg_list.h" @@ -391,6 +392,17 @@ ExplainOnePlan(PlannedStmt *plannedstmt, ParamListInfo params, None_Receiver, params, stmt->analyze); + if (gp_enable_gpperfmon && Gp_role == GP_ROLE_DISPATCH) + { + Assert(queryString); + gpmon_qlog_query_submit(queryDesc->gpmon_pkt); + gpmon_qlog_query_text(queryDesc->gpmon_pkt, + queryString, + application_name, + GetResqueueName(GetResQueueId()), + GetResqueuePriority(GetResQueueId())); + } + /* Initialize ExplainState structure. */ es = (ExplainState *) palloc0(sizeof(ExplainState)); es->pstmt = queryDesc->plannedstmt; diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 23ecfbbf9f..1641f8d05c 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -1416,22 +1416,6 @@ PortalRunUtility(Portal portal, Node *utilityStmt, bool isTopLevel, ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); else ActiveSnapshot = NULL; - gpmon_packet_t *gpmon_pkt = NULL; - if(gp_enable_gpperfmon && Gp_role == GP_ROLE_DISPATCH) - { - gpmon_pkt = (gpmon_packet_t *) palloc0(sizeof(gpmon_packet_t)); - gpmon_qlog_packet_init(gpmon_pkt); - /* set gpmon_pkt->u.qlog.key.ccnt to 0 in utility mode becasue the gp_command_count is changing */ - gpmon_pkt->u.qlog.key.ccnt = 0; - gpmon_qlog_query_submit(gpmon_pkt); - gpmon_qlog_query_text(gpmon_pkt, - portal->sourceText ? portal->sourceText: "(Source text for portal is not available)", - application_name, - GetResqueueName(portal->queueId), - GetResqueuePriority(portal->queueId)); - gpmon_qlog_query_start(gpmon_pkt); - } - /* check if this utility statement need to be involved into resoure queue * mgmt */ @@ -1450,12 +1434,6 @@ PortalRunUtility(Portal portal, Node *utilityStmt, bool isTopLevel, if (ActiveSnapshot) FreeSnapshot(ActiveSnapshot); ActiveSnapshot = NULL; - - if(gp_enable_gpperfmon && Gp_role == GP_ROLE_DISPATCH) - { - gpmon_qlog_query_end(gpmon_pkt); - pfree(gpmon_pkt); - } } /* -- GitLab