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


##########
fe/fe-core/src/main/java/org/apache/doris/mysql/ReadListener.java:
##########
@@ -46,23 +48,29 @@ public void handleEvent(ConduitStreamSourceChannel channel) 
{
         XnioIoThread.requireCurrentThread();
         ctx.suspendAcceptQuery();
         // start async query handle in task thread.
-        channel.getWorker().execute(() -> {
-            ctx.setThreadLocalInfo();
-            try {
-                connectProcessor.processOnce();
-                if (!ctx.isKilled()) {
-                    ctx.resumeAcceptQuery();
-                } else {
-                    ctx.stopAcceptQuery();
+        try {
+            channel.getWorker().execute(() -> {
+                ctx.setThreadLocalInfo();
+                try {
+                    connectProcessor.processOnce();
+                    if (!ctx.isKilled()) {
+                        ctx.resumeAcceptQuery();
+                    } else {
+                        ctx.stopAcceptQuery();
+                        ctx.cleanup();
+                    }
+                } catch (Throwable e) {
+                    LOG.warn("Exception happened in one session(" + ctx + 
").", e);
+                    ctx.setKilled();
                     ctx.cleanup();
+                } finally {
+                    ConnectContext.remove();
                 }
-            } catch (Throwable e) {
-                LOG.warn("Exception happened in one session(" + ctx + ").", e);
-                ctx.setKilled();
-                ctx.cleanup();
-            } finally {
-                ConnectContext.remove();
-            }
-        });
+            });
+        } catch (RejectedExecutionException e) {
+            LOG.warn("Failed to submit query task for one session({}).", ctx, 
e);
+            ctx.setKilled();

Review Comment:
   This branch skips the normal `ctx.setThreadLocalInfo()` / 
`ConnectContext.remove()` lifecycle, but `cleanup()` can still tear down 
transaction state through the connection close listener. 
`ConnectPoolMgr.unregisterConnection()` calls `ctx.closeTxn()`, and the 
observer rollback path in `TransactionEntry.abortTransaction()` builds 
`MasterOpExecutor` / `MasterTxnExecutor` from `ConnectContext.get()`. For a 
session that already owns a transaction, a rejected worker task here can 
therefore fail to abort the txn and leak server-side transaction state. The 
mocked test will not catch that because it never exercises a real registered 
connection / txn cleanup path.



##########
fe/fe-core/src/main/java/org/apache/doris/mysql/ReadListener.java:
##########
@@ -46,23 +48,29 @@ public void handleEvent(ConduitStreamSourceChannel channel) 
{
         XnioIoThread.requireCurrentThread();
         ctx.suspendAcceptQuery();
         // start async query handle in task thread.
-        channel.getWorker().execute(() -> {
-            ctx.setThreadLocalInfo();
-            try {
-                connectProcessor.processOnce();
-                if (!ctx.isKilled()) {
-                    ctx.resumeAcceptQuery();
-                } else {
-                    ctx.stopAcceptQuery();
+        try {
+            channel.getWorker().execute(() -> {
+                ctx.setThreadLocalInfo();
+                try {
+                    connectProcessor.processOnce();
+                    if (!ctx.isKilled()) {
+                        ctx.resumeAcceptQuery();
+                    } else {
+                        ctx.stopAcceptQuery();
+                        ctx.cleanup();
+                    }
+                } catch (Throwable e) {
+                    LOG.warn("Exception happened in one session(" + ctx + 
").", e);
+                    ctx.setKilled();
                     ctx.cleanup();
+                } finally {
+                    ConnectContext.remove();
                 }
-            } catch (Throwable e) {
-                LOG.warn("Exception happened in one session(" + ctx + ").", e);
-                ctx.setKilled();
-                ctx.cleanup();
-            } finally {
-                ConnectContext.remove();
-            }
-        });
+            });
+        } catch (RejectedExecutionException e) {
+            LOG.warn("Failed to submit query task for one session({}).", ctx, 
e);
+            ctx.setKilled();

Review Comment:
   `handleEvent()` is still running on the XNIO I/O thread here. Calling full 
`ctx.cleanup()` from this rejection path moves heavyweight session teardown 
back onto the event loop: `cleanup()` may drop temp tables directly or forward 
to master, and connection close can synchronously drive transaction abort. 
Under the same overload condition that causes `RejectedExecutionException`, 
this can stall the I/O thread and hurt unrelated connections.



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