github-actions[bot] commented on code in PR #69566:
URL: https://github.com/apache/doris/pull/69566#discussion_r4366239544


##########
fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java:
##########
@@ -281,6 +285,21 @@ protected void handleExecute(PrepareCommand 
prepareCommand, long stmtId, Prepare
         }
     }
 
+    /**
+     * COM_STMT_EXECUTE has no per-statement close like the one COM_QUERY runs 
in its finally. An execution that
+     * fails after its scans were planned, such as one a scan-level SQL block 
rule rejects or a prepared
+     * INSERT ... SELECT whose transaction fails to begin, never reaches 
unregisterQuery: the query-finish callbacks
+     * its scans registered (releasing a connector read transaction, closing 
the connector scope) would stay in the
+     * registry for good, its connector scope would stay open until the 
statement's next EXECUTE, and scan nodes left
+     * for the statement end would never stop. The context ExecuteCommand ran 
this execution with is the prepared
+     * statement's current one (see 
PreparedStatementContext#nextStatementContext). Both calls are no-ops for an
+     * execution that finished normally, which already unregistered its query 
and closed its scope.
+     */
+    private void finishExecution(PreparedStatementContext prepCtx) {
+        QeProcessorImpl.INSTANCE.unregisterQuery(ctx.queryId());

Review Comment:
   [P2] Wait for split producers before closing the execution scope
   
   An Iceberg streaming scan can hit the first-split timeout while its producer 
is already running but has not reached the statement-scope lookup; for example, 
scheduler backlog can start it just before the 30-second deadline. 
`unregisterQuery()` runs the scan's stop callback and then 
`QueryFinishCleanup`, which calls `statementScope.closeAll()`, but 
`SplitProducer.close()` only requests cancellation and does not wait for that 
running producer. The producer can therefore resume after the scope was cleared 
and insert a new `ScopedBorrow`/tracked table through `computeIfAbsent` on the 
already-closed scope. Its split source closes only task iterators, while 
subsequent `closeAll()` calls (including the next EXECUTE's reset) return 
immediately because `closed` is already true, permanently retaining the 
table/FileIO/catalog lease. Previously, if the producer finished before the 
next EXECUTE, the still-open outgoing scope released that holder at reset. 
Quiesce producers before closing their
  scope, or defer scope teardown until they complete, and cover timeout versus 
in-flight scope lookup.



-- 
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