GJ100 opened a new pull request, #68178:
URL: https://github.com/apache/doris/pull/68178

   ### What problem does this PR solve?
   
   Issue Number: close #68169
   
   Problem Summary:
   When a MySQL client terminates its connection abruptly (e.g., client-side 
timeout elapsed while BE was slow or waiting for lock), FE's network layer 
invokes ConnectPoolMgr.unregisterConnection(context).
   
   However, unregisterConnection previously only removed the context from 
connectionMap without cancelling the running query. This caused multiple severe 
issues:
   1. Timeout Checker Bypass: FE's TimeoutChecker (checkTimeout) only inspects 
connections present in connectionMap.values(). Once removed, the connection is 
never checked again, allowing the orphaned query to bypass query_timeout 
entirely and run indefinitely.
   2. Ghost Queries in active_queries: The query stayed RUNNING indefinitely in 
QeProcessorImpl and information_schema.active_queries because the coordinator 
was never finalized.
   3. Workload Group Concurrency Starvation: The query never released its 
QueueToken in WorkloadGroup. When all group slots were consumed by such 
orphaned queries, all subsequent queries became permanently queued in 
WAIT_IN_QUEUE until timing out.
   
   Fix:
   1. In ConnectPoolMgr.unregisterConnection(), asynchronously cancel running 
queries via ctx.cancelQuery(..., false) without blocking the XNIO 
close-listener thread, ensuring coordinator aborts BE fragment execution, 
releases workload group QueueTokens, and unblocks waiting FE threads.
   2. Added cancelQuery(Status, boolean needWaitCancelComplete) in 
ConnectContext and defensive cancelQuery calls in 
ConnectContext.killConnection() and cleanup().
   3. Added unit tests in ConnectSchedulerTest and ConnectContextTest.
   
   ### Release note
   
   Fix orphaned queries hanging in information_schema.active_queries and 
leaking Workload Group concurrency slots when clients disconnect.
   
   ### Check List (For Author)
   
   - Test
       - [ ] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
   - Behavior changed: No
   - Does this need documentation: No


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