aminghadersohi opened a new pull request, #44581:
URL: https://github.com/apache/superset/pull/44581

   ### SUMMARY
   Prevent synchronous warehouse calls from freezing the MCP transport loop. 
Run protected async tools in isolated thread workers, including indirect chart, 
dataset, preview, and metadata-discovery query paths.
   
   Design choices:
   - `MCP_TOOL_WORKERS=16` bounds admission; saturation returns “server busy” 
immediately.
   - Use the request timeout, or `SQLLAB_TIMEOUT` when absent, for the whole 
call. Composed calls share that deadline.
   - Reuse engine cancellation IDs/hooks and implicit cursor cancellation on a 
separate bounded pool. Uncancellable queries retain their slot; stuck 
cancellation also retains admission. No shared engine-spec statement-timeout 
API exists, so MCP does not rely on process-wide SIGALRM.
   - Each worker owns its app context/session. Invalidate failed-query sessions 
and safely remove them before teardown; preserve acting-user and transport 
context.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Not applicable. Sleeping queries no longer prevent another MCP request from 
completing, and callers receive a clear timeout error at their deadline.
   
   ### TESTING INSTRUCTIONS
   - Four timing regressions using real sleeping SQLite queries through 
chart/SQL Lab execution fail on `origin/master` (`c0c688d3e4`) and pass here.
   - Worker tests cover overload, cancellation (including late handles), 
cleanup, and context isolation.
   - MCP, SQL executor, model, and cancellation unit suites; pre-commit, Ruff, 
and mypy.
   
   ### ADDITIONAL INFORMATION
   No feature flag, migration, or UI change. Driver cancellation is 
best-effort; a timeout does not guarantee warehouse writes were rolled back.
   


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