From 0c260152b7d07f424456d2543633f0d279e43902 Mon Sep 17 00:00:00 2001 From: luozenglin <37725793+luozenglin@users.noreply.github.com> Date: Fri, 9 Sep 2022 22:58:04 +0800 Subject: [PATCH] [fix](profile) fix query instance profile may be lost. (#12418) --- .../main/java/org/apache/doris/qe/StmtExecutor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 76b3106dbd..93779ad212 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -245,8 +245,12 @@ public class StmtExecutor implements ProfileWriter { plannerProfile.initRuntimeProfile(plannerRuntimeProfile); queryProfile.getCounterTotalTime().setValue(TimeUtils.getEstimatedTime(plannerProfile.getQueryBeginTime())); - if (coord != null) { - coord.endProfile(waiteBeReport); + endProfile(waiteBeReport); + } + + private void endProfile(boolean waitProfileDone) { + if (context != null && context.getSessionVariable().enableProfile() && coord != null) { + coord.endProfile(waitProfileDone); } } @@ -466,6 +470,10 @@ public class StmtExecutor implements ProfileWriter { throw e; } } finally { + // The final profile report occurs after be returns the query data, and the profile cannot be + // received after unregisterQuery(), causing the instance profile to be lost, so we should wait + // for the profile before unregisterQuery(). + endProfile(true); QeProcessorImpl.INSTANCE.unregisterQuery(context.queryId()); } } @@ -1472,6 +1480,7 @@ public class StmtExecutor implements ProfileWriter { */ throwable = t; } finally { + endProfile(true); QeProcessorImpl.INSTANCE.unregisterQuery(context.queryId()); }