924060929 commented on code in PR #66913:
URL: https://github.com/apache/doris/pull/66913#discussion_r3838730741


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java:
##########
@@ -73,6 +73,9 @@ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
     @Override
     public void run(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
         StatementContext statementContext = ctx.getStatementContext();
+        // PREPARE retains this StatementContext, but ConnectProcessor closes 
the resources from each
+        // COM_STMT_EXECUTE. Reopen an empty generation before the next 
execution starts planning.
+        statementContext.beginStatementResourceGeneration();

Review Comment:
   这条评论涉及通用查询、任务、Streaming、Flight、Hive 或其他非本 PR 生命周期问题,不属于本 PR 仅处理 Hudi/Iceberg 
资源关闭与泄露的范围。当前 head 已撤回对应旁支改动,本 PR 忽略该问题。



##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -969,16 +971,64 @@ public boolean isDeferredForArrowFlight() {
         return deferredForArrowFlight;
     }
 
+    void deferArrowFlightQuery() {
+        Closeable resources = statementContext.detachStatementResources();
+        deferredArrowFlightStatementResources = resources;
+        deferredForArrowFlight = true;
+        try {
+            context.addFlightSqlDeferredExecutor(this);

Review Comment:
   这条评论涉及通用查询、任务、Streaming、Flight、Hive 或其他非本 PR 生命周期问题,不属于本 PR 仅处理 Hudi/Iceberg 
资源关闭与泄露的范围。当前 head 已撤回对应旁支改动,本 PR 忽略该问题。



##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -984,21 +984,84 @@ public PlSqlOperation getPlSqlOperation() {
     // with "Split source X is released". These executors are finalized when 
the next query starts
     // on this connection, or when the connection is torn down. See #62259.
     private final List<StmtExecutor> flightSqlDeferredExecutors = new 
ArrayList<>();
+    private boolean flightSqlDeferredExecutorsSealed;
+    private int flightSqlResultPublishers;
 
-    public void addFlightSqlDeferredExecutor(StmtExecutor executor) {
+    public boolean addFlightSqlDeferredExecutor(StmtExecutor executor) {
         synchronized (flightSqlDeferredExecutors) {
+            if (flightSqlDeferredExecutorsSealed) {
+                return false;
+            }
             flightSqlDeferredExecutors.add(executor);
+            return true;
+        }
+    }
+
+    /** Linearizes GetFlightInfo publication with the terminal session seal. */
+    public boolean canPublishFlightSqlResult() {
+        synchronized (flightSqlDeferredExecutors) {
+            return !flightSqlDeferredExecutorsSealed;
+        }
+    }
+
+    public boolean beginFlightSqlResultPublication() {
+        synchronized (flightSqlDeferredExecutors) {
+            if (flightSqlDeferredExecutorsSealed) {
+                return false;
+            }
+            flightSqlResultPublishers++;
+            return true;
+        }
+    }
+
+    public void endFlightSqlResultPublication() {
+        List<StmtExecutor> toClose = null;
+        synchronized (flightSqlDeferredExecutors) {
+            if (--flightSqlResultPublishers == 0 && 
flightSqlDeferredExecutorsSealed) {

Review Comment:
   这条评论涉及通用查询、任务、Streaming、Flight、Hive 或其他非本 PR 生命周期问题,不属于本 PR 仅处理 Hudi/Iceberg 
资源关闭与泄露的范围。当前 head 已撤回对应旁支改动,本 PR 忽略该问题。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to