diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java index 42cd4e096e8933a..5dd3c0d507ba557 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java @@ -820,14 +820,6 @@ public void addReturnResultFromRemoteExecutor(StmtExecutor executor) { public void finalizeArrowFlightSqlRequest() { setThreadLocalInfo(); - for (StmtExecutor asynExecutor : returnResultFromRemoteExecutor) { - asynExecutor.finalizeQuery(); - } - returnResultFromRemoteExecutor.clear(); - // In most cases, `executor.finalizeQuery` is redundant and will be skipped directly. - // Because the query returning results from BE will execute `returnResultFromRemoteExecutor.finalizeQuery`, - // and the query returning results from FE and `insert into` will call unregisterQuery after execute. - executor.finalizeQuery(); if (executor != null && executor.getParsedStmt() != null && !executor.getParsedStmt().isExplain() && (executor.getParsedStmt() instanceof QueryStmt // currently only QueryStmt and insert need profile || executor.getParsedStmt() instanceof LogicalPlanAdapter @@ -838,6 +830,15 @@ public void finalizeArrowFlightSqlRequest() { } } + for (StmtExecutor asynExecutor : returnResultFromRemoteExecutor) { + asynExecutor.finalizeQuery(); + } + returnResultFromRemoteExecutor.clear(); + // In most cases, `executor.finalizeQuery` is redundant and will be skipped directly. + // Because the query returning results from BE will execute `returnResultFromRemoteExecutor.finalizeQuery`, + // and the query returning results from FE and `insert into` will call unregisterQuery after execute. + executor.finalizeQuery(); + remove(); setCommand(MysqlCommand.COM_SLEEP); clear();